public class ThreadLocalTransferHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.Set<java.lang.ThreadLocal<java.lang.Object>> |
THREADLOCALS
The registered thread locals.
|
protected java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> |
vals
The thread locals.
|
Constructor and Description |
---|
ThreadLocalTransferHelper()
Create a new transfer helper.
|
ThreadLocalTransferHelper(boolean beforeswitch)
Create a new transfer helper.
|
Modifier and Type | Method and Description |
---|---|
static void |
addThreadLocal(java.lang.ThreadLocal<?> tl)
Add a thread local that will be automatically copied on thread resumption.
|
void |
afterSwitch()
Must be called after a thread switch occurs to restore the thread local values.
|
void |
beforeSwitch()
Must be called before a thread switch occurs to save the thread local values.
|
static void |
removeThreadLocal(java.lang.ThreadLocal<?> tl)
Add a thread local that will be automatically copied on thread resumption.
|
static void |
restoreValues(java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> vals)
Method to be called on new thread on resumption.
|
static java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> |
saveValues()
Method to be called on old thread before thread switch.
|
protected static final java.util.Set<java.lang.ThreadLocal<java.lang.Object>> THREADLOCALS
protected java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> vals
public ThreadLocalTransferHelper()
public ThreadLocalTransferHelper(boolean beforeswitch)
public static java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> saveValues()
public static void restoreValues(java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> vals)
public static void addThreadLocal(java.lang.ThreadLocal<?> tl)
public static void removeThreadLocal(java.lang.ThreadLocal<?> tl)
public void beforeSwitch()
public void afterSwitch()