Class ThreadSynchronization

java.lang.Object
org.jppf.utils.concurrent.ThreadSynchronization
Direct Known Subclasses:
AbstractHeartbeatConnection, AbstractJMXConnectionWrapper, AbstractProcessLauncher, CPUTimeCollector, JPPFBroadcaster, JPPFMulticastReceiver

public class ThreadSynchronization extends Object
This class implements a goToSleep and a wakeUp method as wrappers to Object.wait() and Object.notifyAll() wrappers.
Author:
Laurent Cohen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Determines whether the thread's run() method should terminate.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cause the current thread to wait until notified.
    void
    goToSleep(long time)
    Cause the current thread to wait until notified or the specified time has passed, whichever comes first.
    void
    goToSleep(long millis, int nanos)
    Cause the current thread to wait until notified or the specified time has passed, whichever comes first.
    boolean
    Determine whether the thread's run() method is terminated.
    void
    setStopped(boolean stopped)
    Specify whether the thread's run() should terminate.
    void
    Notify the threads currently waiting on this object that they can resume.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • stopped

      protected boolean stopped
      Determines whether the thread's run() method should terminate.
  • Constructor Details

    • ThreadSynchronization

      public ThreadSynchronization()
  • Method Details

    • goToSleep

      public void goToSleep()
      Cause the current thread to wait until notified.
    • goToSleep

      public void goToSleep(long time)
      Cause the current thread to wait until notified or the specified time has passed, whichever comes first.
      Parameters:
      time - the maximum time to wait in milliseconds.
    • goToSleep

      public void goToSleep(long millis, int nanos)
      Cause the current thread to wait until notified or the specified time has passed, whichever comes first.
      Parameters:
      millis - the maximum time to wait in milliseconds.
      nanos - the additional time to wait in nanoseconds.
    • wakeUp

      public void wakeUp()
      Notify the threads currently waiting on this object that they can resume.
    • isStopped

      public boolean isStopped()
      Determine whether the thread's run() method is terminated.
      Returns:
      true if the thread is stopped, false otherwise.
    • setStopped

      public void setStopped(boolean stopped)
      Specify whether the thread's run() should terminate.
      Parameters:
      stopped - true if the thread is to be stopped, false otherwise.