public class SingleWaiterMultiNotifier extends Object implements Notifier
await() method is analogous to an imaginary "take all" variant of the BlockingQueue.take() method, and the signal() method is analogous to BlockingQueue.put().
Note that no synchronization is needed to use this class; i.e. clients must not synchronize on this class prior to calling await() or signal(), nor should the use any of the primitive wait() or notify() methods.
| Modifier and Type | Field and Description |
|---|---|
protected Object |
m_oState
The signaling state, null for unsignaled, this for signaled, or a thread for the single awaiting thread
|
| Constructor and Description |
|---|
SingleWaiterMultiNotifier() |
| Modifier and Type | Method and Description |
|---|---|
void |
await()
Wait for a notification (which may have already occurred).
|
void |
await(long cMillis)
Wait for a notification (which may have already occurred).
|
protected void |
consumeSignal()
Consume the signal.
|
Thread |
getWaitingThread()
Return the thread which is waiting on this notifier.
|
void |
signal()
Notifies the waiting thread(s), waking them up if awaiting, or preventing the next thread from going to sleep on the next await attempt.
|
protected Thread |
signalInternal()
Signal the notifier returning any thread which needs to be unparked.
|
String |
toString() |
protected volatile Object m_oState
public void await()
throws InterruptedException
Notifierawait in interface NotifierInterruptedException - if the calling thread is interrupted while it is waiting
public void await(long cMillis)
throws InterruptedException
Notifierawait in interface NotifiercMillis - the maximum wait time in milliseconds, or zero for indefiniteInterruptedException - if the calling thread is interrupted while it is waitingpublic void signal()
Notifierpublic Thread getWaitingThread()
protected Thread signalInternal()
protected void consumeSignal()