You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:point_right: Transmit multi-thread context, even using thread cached components like thread pool.
19
+
:point_right: Transmit `ThreadLocal` value between threads, even using thread cached components like thread pool.
20
20
21
21
Class [`java.lang.InheritableThreadLocal`](http://docs.oracle.com/javase/6/docs/api/java/lang/InheritableThreadLocal.html) in `JDK`
22
-
can transmit context to child thread from parent thread.
22
+
can transmit value to child thread from parent thread.
23
23
24
-
But when use thread pool, thread is cached up and used repeatedly. Transmitting context from parent thread to child thread has no meaning.
25
-
Application need transmit context from the time task is created to the time task is executed.
24
+
But when use thread pool, thread is cached up and used repeatedly. Transmitting value from parent thread to child thread has no meaning.
25
+
Application need transmit value from the time task is created to the time task is executed.
26
26
27
27
If you have problem or question, please [submit Issue](https://github.com/alibaba/multi-thread-context/issues) or play [fork](https://github.com/alibaba/multi-thread-context/fork) and pull request dance.
28
28
29
29
:art: Requirements
30
30
----------------------------
31
31
32
-
The Requirements listed below is also why I sort out `MTC` in my work.
32
+
The Requirements listed below is also why I sort out `TTL` in my work.
33
33
34
34
* Application container or high layer framework transmit information to low layer sdk.
35
35
* Transmit context to logging without application code aware.
@@ -42,7 +42,7 @@ The Requirements listed below is also why I sort out `MTC` in my work.
This is the function of class [`java.lang.InheritableThreadLocal`](http://docs.oracle.com/javase/6/docs/api/java/lang/InheritableThreadLocal.html), should use class [`java.lang.InheritableThreadLocal`](http://docs.oracle.com/javase/6/docs/api/java/lang/InheritableThreadLocal.html) instead.
55
55
56
-
But when use thread pool, thread is cached up and used repeatedly. Transmitting context from parent thread to child thread has no meaning.
57
-
Application need transmit context from the time task is created to the point task is executed.
56
+
But when use thread pool, thread is cached up and used repeatedly. Transmitting value from parent thread to child thread has no meaning.
57
+
Application need transmit value from the time task is created to the point task is executed.
58
58
59
59
The solution is below usage.
60
60
61
-
2. Transmit context even using thread pool
61
+
2. Transmit value even using thread pool
62
62
----------------------------
63
63
64
64
### 2.1 Decorate `Runnable` and `Callable`
65
65
66
-
Decorate input `Runnable` and `Callable` by [`com.alibaba.mtc.MtContextRunnable`](src/main/java/com/alibaba/mtc/MtContextRunnable.java)
67
-
and [`com.alibaba.mtc.MtContextCallable`](src/main/java/com/alibaba/mtc/MtContextCallable.java).
66
+
Decorate input `Runnable` and `Callable` by [`com.alibaba.ttl.TtlRunnable`](/src/main/java/com/alibaba/ttl/TtlRunnable.java)
67
+
and [`com.alibaba.ttl.TtlCallable`](src/main/java/com/alibaba/ttl/TtlCallable.java).
Check available version at [search.maven.org](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.alibaba%22%20AND%20a%3A%22multithread.context%22).
204
+
Check available version at [search.maven.org](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.alibaba%22%20AND%20a%3A%22transmittable-thread-local%22).
0 commit comments