public class BlockingBoolean
extends java.util.concurrent.locks.AbstractQueuedSynchronizer
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,
java.util.concurrent.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
public BlockingBoolean(boolean value)
value
- the starting valuepublic void await(boolean value) throws java.lang.InterruptedException
value
- specified valuejava.lang.InterruptedException
- if interrupted while waitingpublic boolean await(boolean value, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.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 zerojava.lang.InterruptedException
- if interrupted while waitingprotected int tryAcquireShared(int acquires)
tryAcquireShared
in class java.util.concurrent.locks.AbstractQueuedSynchronizer
public void set(boolean value)
value
- new valuepublic boolean get()
protected boolean tryReleaseShared(int releases)
tryReleaseShared
in class java.util.concurrent.locks.AbstractQueuedSynchronizer