java.lang
Class InheritableThreadLocal
java.lang.Object
|
+--java.lang.ThreadLocal
|
+--java.lang.InheritableThreadLocal
A ThreadLocal whose value is inherited by child Threads. The value of the
InheritableThreadLocal associated with the (parent) Thread is copied to
the new (child) Thread at the moment of creation.
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.
Since:Authors:- Mark Wielaard <mark@klomp.org>
- Eric Blake <ebb9@email.byu.edu>
See Also:
InheritableThreadLocal
public InheritableThreadLocal()
Creates a new InheritableThreadLocal that has no values associated
with it yet.
childValue
protected Object childValue(java.lang.Object parentValue)
Determines the value associated with a newly created child Thread as a
function of the value associated with the currently executing (parent)
Thread. The default implementation just returns the parentValue.
Parameters:
Returns:
- the initial value for the child thread
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.