@ThreadSafe
public final class AdjustableSemaphore
extends java.lang.Object
| Constructor and Description |
|---|
AdjustableSemaphore(int maxPermits)
New instances should be configured with setMaxPermits().
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Get a permit, blocking if necessary.
|
int |
availablePermits() |
void |
release()
Release a permit back to the semaphore.
|
void |
setMaxPermits(int newMax)
Set the max number of permits.
|
boolean |
tryAcquire(long timeout,
java.util.concurrent.TimeUnit unit) |
public AdjustableSemaphore(int maxPermits)
public void setMaxPermits(int newMax)
newMax - public void release()
public void acquire()
throws java.lang.InterruptedException
java.lang.InterruptedException - if interrupted while waiting for a permitpublic boolean tryAcquire(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic int availablePermits()