Package org.jppf.utils.concurrent
Class ThreadSynchronization
java.lang.Object
org.jppf.utils.concurrent.ThreadSynchronization
- Direct Known Subclasses:
AbstractHeartbeatConnection,AbstractJMXConnectionWrapper,AbstractProcessLauncher,CPUTimeCollector,JPPFBroadcaster,JPPFMulticastReceiver
This class implements a goToSleep and a wakeUp method as wrappers to
Object.wait() and
Object.notifyAll() wrappers.- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanDetermines whether the thread's run() method should terminate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCause the current thread to wait until notified.voidgoToSleep(long time) Cause the current thread to wait until notified or the specified time has passed, whichever comes first.voidgoToSleep(long millis, int nanos) Cause the current thread to wait until notified or the specified time has passed, whichever comes first.booleanDetermine whether the thread'srun()method is terminated.voidsetStopped(boolean stopped) Specify whether the thread'srun()should terminate.voidwakeUp()Notify the threads currently waiting on this object that they can resume.
-
Field Details
-
stopped
protected boolean stoppedDetermines 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'srun()method is terminated.- Returns:
- true if the thread is stopped, false otherwise.
-
setStopped
public void setStopped(boolean stopped) Specify whether the thread'srun()should terminate.- Parameters:
stopped- true if the thread is to be stopped, false otherwise.
-