public abstract class QueuedSemaphore extends Semaphore
| Modifier and Type | Class and Description |
|---|---|
protected static class |
QueuedSemaphore.WaitQueue
Base class for internal queue classes for semaphores, etc.
|
| Modifier and Type | Field and Description |
|---|---|
protected QueuedSemaphore.WaitQueue |
wq_ |
ONE_CENTURY, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR| 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.
|
protected QueuedSemaphore.WaitQueue.WaitNode |
getSignallee() |
protected boolean |
precheck() |
protected boolean |
recheck(QueuedSemaphore.WaitQueue.WaitNode w) |
void |
release()
Release a permit
|
void |
release(long n)
Release N permits
|
protected final QueuedSemaphore.WaitQueue wq_
public void acquire()
throws java.lang.InterruptedException
Semaphorepublic boolean attempt(long msecs)
throws java.lang.InterruptedException
Semaphoreattempt in interface Syncattempt in class Semaphoremsecs - 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.InterruptedExceptionprotected boolean precheck()
protected boolean recheck(QueuedSemaphore.WaitQueue.WaitNode w)
protected QueuedSemaphore.WaitQueue.WaitNode getSignallee()
public void release()
Semaphore