public class TransmittableThreadLocal<T> extends InheritableThreadLocal<T>
TransmittableThreadLocal can transmit value from the thread of submitting task to the thread of executing task.
Note: this class extends InheritableThreadLocal,
so TransmittableThreadLocal first is a InheritableThreadLocal.
TtlRunnable,
TtlCallable| Constructor and Description |
|---|
TransmittableThreadLocal() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute()
Callback method after task object(
TtlRunnable/TtlCallable) execute. |
protected void |
beforeExecute()
Callback method before task object(
TtlRunnable/TtlCallable) execute. |
protected T |
copy(T parentValue)
Computes the value for this transmittable thread-local variable
as a function of the source thread's value at the time the task
Object is created.
|
T |
get() |
void |
remove() |
void |
set(T value) |
childValueinitialValue, withInitialprotected T copy(T parentValue)
TtlRunnable or
TtlCallable when it create, before the task is started.
This method merely returns reference of its source thread value, and should be overridden if a different behavior is desired.
protected void beforeExecute()
TtlRunnable/TtlCallable) execute.
Default behavior is do nothing, and should be overridden if a different behavior is desired.
Do not throw any exception, just ignored.
protected void afterExecute()
TtlRunnable/TtlCallable) execute.
Default behavior is do nothing, and should be overridden if a different behavior is desired.
Do not throw any exception, just ignored.
public final T get()
get in class ThreadLocal<T>public final void set(T value)
set in class ThreadLocal<T>public final void remove()
remove in class ThreadLocal<T>Copyright © 2013–2016 Alibaba. All rights reserved.