# alibaba/transmittable-thread-local

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/alibaba-transmittable-thread-local).**

8,291 stars · 1,721 forks · Java · Apache-2.0

## Links

- GitHub: https://github.com/alibaba/transmittable-thread-local
- Homepage: https://github.com/alibaba/transmittable-thread-local
- awesome-repositories: https://awesome-repositories.com/repository/alibaba-transmittable-thread-local.md

## Topics

`apm` `async` `async-context` `asynchronous` `asynchronous-context` `context` `dapper` `distributed-tracing` `executor` `forkjoinpool` `framework` `java` `middleware` `thread-pool` `threadlocal` `threadsafe` `tracing` `transmittable` `transmittable-thread-local`

## Description

This project is a Java thread-local extension and context transmitter designed to preserve execution context across asynchronous boundaries. It provides the mechanisms necessary to pass thread-local variables from parent threads to child threads, ensuring data persists when using thread pool executors.

The library enables automatic context transmission through a Java agent that uses bytecode instrumentation to modify thread pool implementations without requiring source code changes. It also supports transparent instrumentation via executor service wrapping and task decoration for Runnable and Callable objects.

The system manages the capturing and restoration of thread-local state to prevent memory leaks and context pollution in reused pools. It includes support for custom value transmission logic to define how objects are copied between different thread contexts.

## Tags

### Programming Languages & Runtimes

- [Bytecode Instrumentation Agents](https://awesome-repositories.com/f/programming-languages-runtimes/bytecode-instrumentation-agents.md) — Provides a Java agent that instruments thread pool implementations to enable automatic context transmission. ([source](https://cdn.jsdelivr.net/gh/alibaba/transmittable-thread-local@master/README.md))
- [Runtime Instrumentation Agents](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-instrumentation-agents.md) — Implements a Java agent that modifies bytecode at runtime to enable context transmission in thread pools.
- [Thread-Local Extensions](https://awesome-repositories.com/f/programming-languages-runtimes/thread-local-extensions.md) — Extends Java's ThreadLocal capabilities to allow variable transmission from parent to child threads in executors.
- [Task Execution Customizers](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/concurrency/task-orchestration-frameworks/thread-pools/custom-thread-pool-configurations/task-execution-customizers.md) — Implements custom task execution logic to capture and restore the current thread context. ([source](https://cdn.jsdelivr.net/gh/alibaba/transmittable-thread-local@master/README.md))
- [Context Value Copying Strategies](https://awesome-repositories.com/f/programming-languages-runtimes/value-identity-determination/context-value-copying-strategies.md) — Allows users to define custom copying logic for objects transferred between different thread contexts.

### Development Tools & Productivity

- [Context-Capturing Task Wrappers](https://awesome-repositories.com/f/development-tools-productivity/task-execution/type-safe-task-wrappers/context-capturing-task-wrappers.md) — Decorates Runnable and Callable tasks to capture and restore thread-local state during execution.
- [Thread Pool Context Propagators](https://awesome-repositories.com/f/development-tools-productivity/task-schedulers/context-propagation/thread-pool-context-propagators.md) — Transmits thread-local context from parent threads to tasks within thread pool executions. ([source](https://cdn.jsdelivr.net/gh/alibaba/transmittable-thread-local@master/README.md))

### Software Engineering & Architecture

- [Background Task Decorators](https://awesome-repositories.com/f/software-engineering-architecture/background-task-decorators.md) — Uses decorators to wrap Runnable and Callable tasks for capturing and restoring execution state.
- [Context-Aware Executor Wrappers](https://awesome-repositories.com/f/software-engineering-architecture/task-scheduling/asynchronous-schedulers/asynchronous-thread-schedulers/custom-thread-executors/asynchronous-task-executors/context-aware-executor-wrappers.md) — Wraps Java executor services to intercept task submission and automatically attach the current thread context.
- [Context-Propagating Executor Wrappers](https://awesome-repositories.com/f/software-engineering-architecture/task-scheduling/asynchronous-schedulers/asynchronous-thread-schedulers/custom-thread-executors/context-propagating-executor-wrappers.md) — Wraps executor services to handle automatic context transmission for all submitted tasks. ([source](https://cdn.jsdelivr.net/gh/alibaba/transmittable-thread-local@master/README.md))
- [Thread-Local Context Management](https://awesome-repositories.com/f/software-engineering-architecture/thread-local-context-management.md) — Captures thread-local values in snapshots to propagate request-scoped state across asynchronous boundaries.

### Data & Databases

- [Context Transmission Logic](https://awesome-repositories.com/f/data-databases/storage-engines/key-value/custom-value-merging/context-transmission-logic.md) — Provides a custom mechanism to handle deep or shallow object copies during cross-thread value transmission. ([source](https://cdn.jsdelivr.net/gh/alibaba/transmittable-thread-local@master/README.md))

### Web Development

- [Request-Scoped State](https://awesome-repositories.com/f/web-development/global-state-access/request-scoped-state.md) — Maintains request-scoped data and security contexts across complex thread boundaries in Java frameworks.
