Package jadex.commons.future
Class ThreadLocalTransferHelper
- java.lang.Object
 - 
- jadex.commons.future.ThreadLocalTransferHelper
 
 
- 
- Direct Known Subclasses:
 ComponentSuspendable,ThreadSuspendable
public class ThreadLocalTransferHelper extends java.lang.ObjectHelps to transfer registered thread local values between different threads. 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected static java.util.Set<java.lang.ThreadLocal<java.lang.Object>>THREADLOCALSThe registered thread locals.protected java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object>valsThe thread locals. 
- 
Constructor Summary
Constructors Constructor Description ThreadLocalTransferHelper()Create a new transfer helper.ThreadLocalTransferHelper(boolean beforeswitch)Create a new transfer helper. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddThreadLocal(java.lang.ThreadLocal<?> tl)Add a thread local that will be automatically copied on thread resumption.voidafterSwitch()Must be called after a thread switch occurs to restore the thread local values.voidbeforeSwitch()Must be called before a thread switch occurs to save the thread local values.static voidremoveThreadLocal(java.lang.ThreadLocal<?> tl)Add a thread local that will be automatically copied on thread resumption.static voidrestoreValues(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. 
 - 
 
- 
- 
Method Detail
- 
saveValues
public static java.util.Map<java.lang.ThreadLocal<java.lang.Object>,java.lang.Object> saveValues()
Method to be called on old thread before thread switch. 
- 
restoreValues
public 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. 
- 
addThreadLocal
public static void addThreadLocal(java.lang.ThreadLocal<?> tl)
Add a thread local that will be automatically copied on thread resumption. 
- 
removeThreadLocal
public static void removeThreadLocal(java.lang.ThreadLocal<?> tl)
Add a thread local that will be automatically copied on thread resumption. 
- 
beforeSwitch
public void beforeSwitch()
Must be called before a thread switch occurs to save the thread local values. 
- 
afterSwitch
public void afterSwitch()
Must be called after a thread switch occurs to restore the thread local values. 
 - 
 
 -