public class ResizableSemaphore extends Semaphore
Semaphore
implementation which performs exactly as a standard Semaphore
, but supports 'resizing'
of the Semaphore
too.Constructor and Description |
---|
ResizableSemaphore(int permits)
Creates a
ResizableSemaphore with the given number of
permits and nonfair fairness setting. |
ResizableSemaphore(int permits,
boolean fair)
Creates a
ResizableSemaphore with the given number of
permits and the given fairness setting. |
Modifier and Type | Method and Description |
---|---|
void |
increasePermits(int increase)
Increase the number of available permits by the amount in the supplied argument.
|
protected void |
reducePermits(int reduction)
Overridden method to stop it being protected.
|
acquire, acquire, acquireUninterruptibly, acquireUninterruptibly, availablePermits, drainPermits, getQueuedThreads, getQueueLength, hasQueuedThreads, isFair, release, release, toString, tryAcquire, tryAcquire, tryAcquire, tryAcquire
public ResizableSemaphore(int permits, boolean fair)
ResizableSemaphore
with the given number of
permits and the given fairness setting.permits
- the initial number of permits available.
This value may be negative, in which case releases
must occur before any acquires will be granted.fair
- true
if this semaphore will guarantee
first-in first-out granting of permits under contention,
else false
public ResizableSemaphore(int permits)
ResizableSemaphore
with the given number of
permits and nonfair fairness setting.permits
- the initial number of permits available.
This value may be negative, in which case releases
must occur before any acquires will be granted.protected void reducePermits(int reduction)
reducePermits
in class Semaphore
reduction
- public void increasePermits(int increase)
increase
- The number of permits to add.Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.