Overview of TransmittableThreadLocal (TTL)
masterTransmittableThreadLocal (TTL) provides the ability to pass ThreadLocal values across thread pools and other execution components that reuse threads.
While the standard JDK InheritableThreadLocal handles value passing from a parent thread to a newly created child thread, it fails in pooled environments where threads are reused. TTL solves this by ensuring that the ThreadLocal value present when a task is submitted to a thread pool is correctly passed to the task's execution context.
Key features:
- Zero dependencies.
- Supports Java 6 to 21 (Note:
v2.13+requires Java 8; usev2.12.xfor Java 6 support). - Extremely lightweight (~1000 SLOC).