public class BlockingBoolean extends AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject
Constructor and Description |
---|
BlockingBoolean(boolean value)
Creates a new blocking boolean with the specified value.
|
Modifier and Type | Method and Description |
---|---|
void |
await(boolean value)
Causes the current thread to wait until the boolean equals the specified
value unless the thread is interrupted.
|
boolean |
await(boolean value,
long timeout,
TimeUnit unit)
Causes the current thread to wait until the boolean equals the specified
value unless the thread is interrupted,
or the specified waiting time elapses.
|
boolean |
get()
Gets the value of the blocking boolean.
|
void |
set(boolean value)
Sets the value of the blocking boolean.
|
protected int |
tryAcquireShared(int acquires) |
protected boolean |
tryReleaseShared(int releases) |
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease
getExclusiveOwnerThread, setExclusiveOwnerThread
public BlockingBoolean(boolean value)
value
- the starting valuepublic void await(boolean value) throws InterruptedException
value
- specified valueInterruptedException
- if interrupted while waitingpublic boolean await(boolean value, long timeout, TimeUnit unit) throws InterruptedException
value
- specified valuetimeout
- the maximum time to waitunit
- the time unit of the timeout
argumenttrue
if the count reached zero and false
if the waiting time elapsed before the count reached zeroInterruptedException
- if interrupted while waitingprotected int tryAcquireShared(int acquires)
tryAcquireShared
in class AbstractQueuedSynchronizer
public void set(boolean value)
value
- new valuepublic boolean get()
protected boolean tryReleaseShared(int releases)
tryReleaseShared
in class AbstractQueuedSynchronizer