Tagged articles
InheritableThreadLocal
20 articles · Page 1 of 1
This article explains how a static ThreadLocal without cleanup in a thread pool causes user data leakage and memory leaks, details ThreadLocalMap's weak-reference Entry structure, demonstrates InheritableThreadLocal's failure with pooled threads, and presents solutions including try-finally cleanup, interceptor-based clearing, Alibaba's TransmittableThreadLocal, and an AutoCloseable wrapper for safe scoping.
AutoCloseableInheritableThreadLocalJava Concurrency
0 likes · 10 min read


XikeSep 9, 2026 · Fundamentals
ThreadLocal provides per-thread variable copies via a ThreadLocalMap with weak-reference keys and strong-reference values, enabling request-context storage and non-thread-safe object reuse, but risks memory leaks in long-lived thread pools unless explicitly removed, and requires careful handling for cross-thread propagation.
Best PracticesInheritableThreadLocalJava Concurrency
0 likes · 14 min read

In Spring Boot 3.5.0, asynchronous threads lose MDC, security, and request data because ThreadLocal is not shared; the article demonstrates five concrete solutions—including InheritableThreadLocal, thread joining, custom TaskDecorator, Spring Security delegating wrappers, and MDC propagation—each with code samples, pitfalls, and best‑practice warnings.
InheritableThreadLocalMDCSpring Security
0 likes · 12 min read

The article explains why InheritableThreadLocal fails to propagate TraceId correctly in high‑concurrency thread‑pool scenarios, demonstrates the mixing problem with concrete request examples, and presents both manual propagation and Alibaba's TransmittableThreadLocal as reliable solutions.
Context PropagationInheritableThreadLocalJava Concurrency
0 likes · 7 min read

The article explains why InheritableThreadLocal fails to propagate TraceId correctly in thread‑pool scenarios under high load, illustrates the problem with concrete request examples, and presents manual propagation and Alibaba's TransmittableThreadLocal as solutions.
InheritableThreadLocalJava ConcurrencyThreadPoolExecutor
0 likes · 7 min read

The article explains ThreadLocal's lifecycle, why userId disappears when spawning asynchronous threads, compares ThreadLocal, InheritableThreadLocal, and Alibaba's TransmittableThreadLocal, and shows how the latter prevents data contamination in thread‑pool reuse.
InheritableThreadLocalJava ConcurrencyThreadLocal
0 likes · 5 min read

This article explains why ThreadLocal values are not automatically transferred in asynchronous or thread‑pool contexts, compares JDK's InheritableThreadLocal with Alibaba's TransmittableThreadLocal (TTL), and shows how TTL captures, replays, and restores context safely with code examples and diagrams.
Context PropagationInheritableThreadLocalJava Concurrency
0 likes · 13 min read

An in‑depth analysis reveals that stale parameters stored in InheritableThreadLocal objects during thread‑pool reuse cause XXL‑Job tasks to process incorrect data, and provides debugging steps and best‑practice recommendations to prevent context pollution.
Context PropagationInheritableThreadLocalJava
0 likes · 10 min read

This article analyzes a null pointer exception caused by InheritableThreadLocal and thread pool reuse, explaining how shared threads in a pool can lead to data corruption when parent thread values are not properly managed.
BackendDevelopmentInheritableThreadLocalNullPointerException
0 likes · 13 min read

An in‑depth analysis reveals how misuse of InheritableThreadLocal with shared thread pools can sporadically produce NullPointerExceptions, detailing the root cause, code examples, debugging steps, and best‑practice recommendations to avoid thread‑local contamination in Java backend services.
ConcurrencyInheritableThreadLocalJava
0 likes · 15 min read

This article explains how ThreadLocal stores values per thread, details the internal set and get mechanisms, discusses potential memory‑leak problems caused by stale entries, and provides best‑practice guidelines such as using remove() and InheritableThreadLocal for child threads.
InheritableThreadLocalJavaMemoryLeak
0 likes · 9 min read

The article explains why regular ThreadLocal cannot share data from a parent thread to its child, introduces InheritableThreadLocal as a built‑in solution, shows its limitation with thread‑pool reuse, and demonstrates how Alibaba's TransmittableThreadLocal overcomes this issue with concrete code examples and output.
ConcurrencyInheritableThreadLocalJava
0 likes · 10 min read

This article explains why client information stored in ThreadLocal becomes unavailable after switching a single‑threaded search service to multithreading, analyzes the underlying ThreadLocal and InheritableThreadLocal mechanisms, and provides two practical solutions—passing the context manually or using InheritableThreadLocal—to avoid the upgrade‑prompt bug.
ConcurrencyInheritableThreadLocalJava
0 likes · 13 min read

This article explains Java's ThreadLocal class, covering its purpose for thread‑local storage, core methods such as get, set, and remove, ways to set initial values via subclassing or withInitial, usage of InheritableThreadLocal for parent‑child thread data propagation, and the underlying implementation details.
InheritableThreadLocalJavaThread Isolation
0 likes · 12 min read

This article explains why ThreadLocal is used in Java concurrency, dives into its internal implementation—including ThreadLocalMap, weak‑referenced keys, hash‑based indexing and resizing—covers common pitfalls such as memory leaks, and shows how InheritableThreadLocal and TransmittableThreadLocal can safely share data across child threads and thread pools.
ConcurrencyInheritableThreadLocalJava
0 likes · 24 min read

This article explains Java's ThreadLocal mechanism, detailing its internal structure, including key methods like set, get, and remove, demonstrates how improper use can cause memory leaks, and provides best practices and examples for safe usage, including InheritableThreadLocal and real-world scenarios.
Best PracticesInheritableThreadLocalMemory Leak
0 likes · 18 min read

This article explains how to make a child thread inherit the values stored in a parent thread's ThreadLocal by using InheritableThreadLocal, demonstrates the behavior with a runnable Java example, and details the underlying ThreadLocalMap mechanism that enables the inheritance.
InheritableThreadLocalThreadLocalbackend development
0 likes · 3 min read

This article explains why ThreadLocal‑based trace information is lost in asynchronous Java calls, compares InheritableThreadLocal and the Alibaba‑provided TransmittableThreadLocal library, shows how to wrap runnables with TtlRunnable, and demonstrates a Java Agent solution for transparent thread‑pool propagation.
InheritableThreadLocalJavaThreadLocal
0 likes · 9 min read

The article explains how to reliably propagate country‑specific context across request handling, database access, and asynchronous thread pools in multi‑country e‑commerce by replacing simple ThreadLocal and InheritableThreadLocal with Alibaba’s TransmittableThreadLocal, demonstrating its integration with Spring MVC/Boot, MyBatis, Dubbo, and custom executors for both sharded and non‑sharded databases.
AlibabaInheritableThreadLocalJava Concurrency
0 likes · 16 min read

This article explains thread safety problems, demonstrates how unsynchronized access to shared variables can produce incorrect results, and shows how Java's ThreadLocal and InheritableThreadLocal classes provide thread‑local storage to avoid concurrency bugs, including implementation details and usage examples.
InheritableThreadLocalJavaThreadLocal
0 likes · 9 min read
