finds.dev

alibaba/transmittable-thread-local

📌 a missing Java std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.

View on GitHubHomepage ↗

★ 8,312JavaApache-2.0updated Jun 2026

// the take

TransmittableThreadLocal (TTL) fixes a real gap in java.lang.InheritableThreadLocal: it doesn't work once you're on a thread pool, because pooled threads aren't children of the submitting thread. TTL captures ThreadLocal values at submission time and replays them on the worker thread, restoring afterward. It's for Java middleware/framework authors who need context propagation (tracing IDs, RPC context, MDC) across ExecutorService, ForkJoinPool, or CompletableFuture boundaries.

Tightly scoped — core logic is ~1000 SLOC with zero dependencies, not a kitchen-sink framework. Offers three integration levels: manual Runnable/Callable wrapping, an ExecutorService decorator (TtlExecutors) that removes per-call wrapping, and a Java agent that bytecode-patches ThreadPoolExecutor/ForkJoinPool/TimerTask for zero code changes. Battle-tested at scale — 8.3k stars and in production use by ShardingSphere, dynamic-tp, hippo4j, and dozens of other real middleware projects, with CI matrixed across JDK 6 through 21. The capture/replay/restore design directly targets a known failure mode: CallerRunsPolicy or ForkJoinPool work-stealing executing tasks on the submitting thread, which breaks naive set/remove ThreadLocal cleanup and causes context leaks or cross-task pollution.

The Java agent path needs manual bootclasspath/load-order configuration and the project's own FAQ documents conflicts with other agents (Skywalking, etc.) depending on load order — fragile in a production stack with multiple agents attached. Primary documentation is Chinese-first; the README-EN exists but is a secondary artifact, which raises friction for non-Chinese-speaking teams evaluating it. The repo is mid-transition — master is an unreleased v3 with its own package namespace (com.alibaba.ttl3) while the actual stable releases people depend on live on the separate 2.x branch, so casual browsers can easily evaluate code that isn't what they'll pull from Maven. Without the agent, propagation is decorator-based: any submission call site you forget to wrap through TtlRunnable/TtlCallable/TtlExecutors just silently drops context instead of failing loudly, which is an easy mistake in a large codebase.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
8,312
Forks
1,722
Language
Java
License
Apache-2.0
Last commit
18 Jun 2026

// nearby

If transmittable-thread-local isn't quite it.

All repos →