Thread Local

ThreadLocal is a parmeterized thread specific data store. It’s usage is simple:

1) InitialValue() or set()

2) call get() during the execution of the thread to obtain the last set() value.

3) Finally, need to clear the value stored in threadLocal by using remove() before the thread has finished executing, so the values are eligible for garbage collection.

InheritableThreadLocal<T> is a subclass of ThreadLocal<T> which copies over the thread local data to each child thread created.

In addition each InheritableThreadLocal can overrider the T childValue(T parentValue) to give child thread specific initialValue based on the parent value.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s