public final class WaiterPreferenceSemaphore extends Semaphore
Modifier and Type | Field and Description |
---|---|
protected long |
waits_
Number of waiting threads
|
ONE_CENTURY, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR
Constructor and Description |
---|
WaiterPreferenceSemaphore(long initial)
Create a Semaphore with the given initial number of permits.
|
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Wait until a permit is available, and take one
|
boolean |
attempt(long msecs)
Wait at most msecs millisconds for a permit.
|
void |
release()
Release a permit
|
void |
release(long n)
Release N permits
|
public WaiterPreferenceSemaphore(long initial)
public void acquire() throws java.lang.InterruptedException
Semaphore
public boolean attempt(long msecs) throws java.lang.InterruptedException
Semaphore
attempt
in interface Sync
attempt
in class Semaphore
msecs
- the number of milleseconds to wait.
An argument less than or equal to zero means not to wait at all.
However, this may still require
access to a synchronization lock, which can impose unbounded
delay if there is a lot of contention among threads.java.lang.InterruptedException
public void release()
Semaphore