alibaba/transmittable-thread-local — explained in plain English
Analysis updated 2026-06-24
Pass a distributed trace ID through all async tasks in a thread pool so your logs stay correlated across threads.
Propagate a user ID or request context from the main thread into pooled worker threads without adding extra method parameters.
Wrap your existing ExecutorService with TTL so all submitted tasks automatically inherit the current thread's context in one line.
Use the Java Agent mode to patch JDK thread pools at startup so TTL works across the whole application without touching existing code.
| alibaba/transmittable-thread-local | krahets/leetcode-book | bytedeco/javacv | |
|---|---|---|---|
| Stars | 8,294 | 8,289 | 8,308 |
| Language | Java | Java | Java |
| Setup difficulty | easy | easy | easy |
| Complexity | 2/5 | 1/5 | 2/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Zero external dependencies, add one Maven or Gradle dependency and wrap your executor in a single method call.
This is a small Java library from Alibaba that solves a specific problem with thread-local storage in Java applications. In Java, developers often store per-request information (like a user ID or trace ID) in a structure called a ThreadLocal, which keeps that data tied to the current thread. Java also has a built-in InheritableThreadLocal that passes that data to child threads, but it breaks down when thread pools are involved, because pooled threads are created once and reused many times rather than spawned fresh for each task. This library provides a class called TransmittableThreadLocal (TTL) that fills that gap. When a task is submitted to a thread pool, TTL captures the current ThreadLocal values from the submitting thread and makes them available inside the task when it runs on a pooled thread. The library has zero external dependencies and is around 1000 lines of code, making it very lightweight to add to a project. There are three ways to use it: wrap individual tasks (Runnable or Callable) with a TTL-aware wrapper before submitting them to a pool, wrap the thread pool itself so all tasks go through TTL automatically, or use a Java Agent that patches the standard JDK thread pool classes at startup without any code changes in the application. Typical use cases mentioned in the documentation include distributed tracing systems (where a trace ID must follow a request through all async work), log context collection, request-scoped caches, and passing configuration from a framework layer down to an SDK. The library supports Java 6 through 21 depending on the version used. The full README is longer than what was shown.
A tiny Java library from Alibaba that fixes a common problem: per-request data like trace IDs stored in ThreadLocal gets lost when tasks run on a reused thread pool thread, this library makes sure it carries through correctly.
Mainly Java. The stack also includes Java, Maven, Gradle.
Setup difficulty is rated easy, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.