java.util.concurrent
Class Semaphore.Sync
java.lang.Object
java.util.concurrent.locks.AbstractQueuedSynchronizer
java.util.concurrent.Semaphore.Sync
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- Semaphore.FairSync, Semaphore.NonfairSync
- Enclosing class:
- Semaphore
abstract static class Semaphore.Sync
- extends AbstractQueuedSynchronizer
Synchronization implementation for semaphore. Uses AQS state
to represent permits. Subclassed into fair and nonfair
versions.
| Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer |
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireShared, tryAcquireSharedNanos, tryRelease |
Semaphore.Sync
Semaphore.Sync(int permits)
getPermits
final int getPermits()
nonfairTryAcquireShared
final int nonfairTryAcquireShared(int acquires)
tryReleaseShared
protected final boolean tryReleaseShared(int releases)
- Description copied from class:
AbstractQueuedSynchronizer
- Attempts to set the state to reflect a release in shared mode.
This method is always invoked by the thread performing release.
The default implementation throws
UnsupportedOperationException
- Overrides:
tryReleaseShared in class AbstractQueuedSynchronizer
- Parameters:
releases - the release argument. This value
is always the one passed to a release method,
or the current state value upon entry to a condition wait.
The value is otherwise uninterpreted and can represent anything
you like.
- Returns:
- true if this object is now in a fully released state,
so that any waiting threads may attempt to acquire; and false
otherwise.
reducePermits
final void reducePermits(int reductions)
drainPermits
final int drainPermits()
Please submit a feedback, bug or feature