public class InheritableThreadLocal<T> extends ThreadLocal<T>
It is possible to make the value associated with the child Thread a
function of the value that is associated with the parent Thread by
overriding the childValue()
method. The utility of this class
is in transferring items like User ID or Transaction ID across threads
automatically.
ThreadLocal
Constructor and Description |
---|
InheritableThreadLocal()
Creates a new InheritableThreadLocal that has no values associated
with it yet.
|
Modifier and Type | Method and Description |
---|---|
protected T |
childValue(T parentValue)
Determines the value associated with a newly created child Thread as a
function of the value associated with the currently executing (parent)
Thread.
|
finalize, get, initialValue, remove, set
public InheritableThreadLocal()
protected T childValue(T parentValue)
parentValue
- the value of this object in the parent thread at
the moment of creation of the child