org.jppf.utils
Class ThreadSynchronization

java.lang.Object
  extended by org.jppf.utils.ThreadSynchronization
Direct Known Subclasses:
AbstractChannelWrapper, AbstractMonitoredNode, AbstractRecoveryConnection, BatchHandler, ChannelSelectorThread, JMXConnectionWrapper, JPPFBroadcaster, JPPFMulticastReceiver, JPPFSubmissionManager, JPPFSubmissionResult, LocalChannelSelector, PeerDiscoveryThread, ProcessLauncher, RecoveryServer, SimpleObjectLock, SubmissionManager, ThreadManager

public abstract 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
protected  boolean stopped
          Determines whether the thread's run() method should terminate.
 
Constructor Summary
ThreadSynchronization()
           
 
Method Summary
 void goToSleep()
          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 isStopped()
          Determine whether the thread's run() method is terminated.
 void setStopped(boolean stopped)
          Specifiy whether the thread's run() should terminate.
 void wakeUp()
          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 Detail

stopped

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

Constructor Detail

ThreadSynchronization

public ThreadSynchronization()
Method Detail

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)
Specifiy whether the thread's run() should terminate.

Parameters:
stopped - true if the thread is to be stopped, false otherwise.


Copyright © 2005-2010 JPPF Team.