public final class OneShotTimeoutBarrier
extends java.lang.Object
OneShotTimeoutBarrier
, like a Token
, is a form
of binary semaphore, but with two differences: (a) the
passWhenOpen(long)
/P() operation has a timeout, and (b) it is
"one-shot" in that the passWhenOpen(long)
method should be
called by a single thread on a single occasion only.Modifier and Type | Method and Description |
---|---|
static OneShotTimeoutBarrier |
newBarrier()
Creates and returns a new one-shot barrier.
|
void |
open()
Opens this barrier provided it has not already timed out; if a thread
is currently blocked on
passWhenOpen(long) , that thread will
be unblocked as a result. |
boolean |
passWhenOpen(long timeout)
Acquires the permission to proceed represented by this barrier,
blocking if necessary until it is opened by another thread
or until the specified timeout has elapsed (more or less), and
returns
true if and only if the barrier is open. |
public static final OneShotTimeoutBarrier newBarrier()
public final boolean passWhenOpen(long timeout) throws java.lang.InterruptedException
true
if and only if the barrier is open.java.lang.InterruptedException
public final void open()
passWhenOpen(long)
, that thread will
be unblocked as a result.