public final class UpperBound
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
java.util.concurrent.Semaphore |
semaphore |
| Constructor and Description |
|---|
UpperBound(int capacity)
Create an UpperBound with the given capacity.
|
| Modifier and Type | Method and Description |
|---|---|
int |
availablePermits() |
void |
release()
Releases one lock on the underlying semaphore.
|
void |
release(int permits)
Releases several locks on the underlying semaphore.
|
java.lang.String |
toString() |
boolean |
tryAcquire(long timeoutInMilliseconds)
Acquires a permit from the underlying semaphore if this UpperBound is bounded and returns
true if it succeeds within the given timeout.
|
public UpperBound(int capacity)
capacity - The capacity.public int availablePermits()
public boolean tryAcquire(long timeoutInMilliseconds)
timeoutInMilliseconds - The time to wait until a permit is available.public void release()
public void release(int permits)
permits - The number of permits to release.public java.lang.String toString()
toString in class java.lang.Object