Package jadex.future

Class ThreadLocalTransferHelper

java.lang.Object
jadex.future.ThreadLocalTransferHelper
Direct Known Subclasses:
ThreadSuspendable

public class ThreadLocalTransferHelper extends Object
Helps to transfer registered thread local values between different threads.
  • Field Details

  • Constructor Details

    • ThreadLocalTransferHelper

      public ThreadLocalTransferHelper()
      Create a new transfer helper.
    • ThreadLocalTransferHelper

      public ThreadLocalTransferHelper(boolean beforeswitch)
      Create a new transfer helper.
  • Method Details

    • saveValues

      public static Map<ThreadLocal<Object>,Object> saveValues()
      Method to be called on old thread before thread switch.
    • restoreValues

      public static void restoreValues(Map<ThreadLocal<Object>,Object> vals)
      Method to be called on new thread on resumption.
    • addThreadLocal

      public static void addThreadLocal(ThreadLocal<?> tl)
      Add a thread local that will be automatically copied on thread resumption.
    • removeThreadLocal

      public static void removeThreadLocal(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.