@ThreadSafety(level=MOSTLY_NOT_THREADSAFE) public final class WakeableSleeper extends java.lang.Object implements java.io.Serializable
WakeableSleeper
instance should be used for each.Constructor and Description |
---|
WakeableSleeper()
Creates a new instance of this wakeable sleeper.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isShutDown()
Return
true if this WakeableSleeper instance has been
shutdown via the shutDown() method and false otherwise. |
void |
shutDown()
Permanently shuts down this
WakeableSleeper instance. |
boolean |
sleep(long time)
Attempts to sleep for the specified length of time in milliseconds, subject
to the accuracy available within the JVM and underlying system.
|
void |
wakeup()
Indicates that the sleeper should wake up if it is currently sleeping.
|
public WakeableSleeper()
public boolean isShutDown()
true
if this WakeableSleeper
instance has been
shutdown via the shutDown()
method and false
otherwise.true
if this WakeableSleeper
instance has been
shutdown via the shutDown()
method and false
otherwise.@ThreadSafety(level=NOT_THREADSAFE) public boolean sleep(long time)
shutDown()
is called, then any active caller of
this method will return immediately, and subsequent calls will return
without sleeping.
WakeableSleeper
instance
by multiple threads at the same time.time
- The length of time in milliseconds to sleep.true
if the sleep completed, or false
if it was
woken or interrupted prematurely.@ThreadSafety(level=COMPLETELY_THREADSAFE) public void shutDown()
WakeableSleeper
instance. If a thread
is currently blocked in the sleep
method, it will return
immediately, and all subsequent calls to that method will return without
sleeping. It is safe to call this method multiple times.@ThreadSafety(level=COMPLETELY_THREADSAFE) public void wakeup()