public final class UpperBound extends Object
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.
|
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.