public final class LocalSemaphore extends Object implements Semaphore
Constructor and Description |
---|
LocalSemaphore(int nrPermits,
boolean fair) |
Modifier and Type | Method and Description |
---|---|
void |
release(int nrPermits)
release a number of permits.
|
String |
toString() |
boolean |
tryAcquire(int nrPermits,
long deadlineNanos) |
boolean |
tryAcquire(int nrPermits,
long timeout,
TimeUnit unit)
try to acquire a number of permits.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
release, toSemaphore
acquire, acquire, tryAcquire
public boolean tryAcquire(int nrPermits, long deadlineNanos) throws InterruptedException
tryAcquire
in interface PermitSupplier
InterruptedException
public boolean tryAcquire(int nrPermits, long timeout, TimeUnit unit) throws InterruptedException
PermitSupplier
tryAcquire
in interface PermitSupplier
nrPermits
- number of permits to acquire.timeout
- time to wait for permits to become available.unit
- units of time.InterruptedException
- - operation interrupted.public void release(int nrPermits)
Semaphore
Copyright © 2018 SPF4J. All rights reserved.