|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jbpm.util.Semaphore
public class Semaphore
A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each acquire blocks if necessary until a permit is available, and then takes it. Each release adds a permit, potentially releasing a blocking acquirer.
| Constructor Summary | |
|---|---|
Semaphore(int permits)
Creates a Semaphore with the given number of permits. |
|
| Method Summary | |
|---|---|
void |
acquire()
Acquires a permit from this semaphore, blocking until one is available, or the thread is interrupted. |
void |
acquire(int permits)
Acquires the given number of permits from this semaphore, blocking until all are available, or the thread is interrupted. |
int |
drainPermits()
Acquire and return all permits that are immediately available. |
void |
release()
Releases a permit, returning it to the semaphore. |
void |
release(int permits)
Releases the given number of permits, returning them to the semaphore. |
boolean |
tryAcquire(int permits,
long timeout)
Acquires the given number of permits from this semaphore, if all become available within the given waiting time and the current thread has not been interrupted. |
boolean |
tryAcquire(long timeout)
Acquires a permit from this semaphore, if one becomes available within the given waiting time and the current thread has not been interrupted. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Semaphore(int permits)
permits - the initial number of permits available. This value may be negative, in which
case releases must occur before any acquires will be granted.| Method Detail |
|---|
public void release()
public void release(int permits)
permits - the number of permits to release
IllegalArgumentException - if permits less than zero.
public void acquire()
throws InterruptedException
interrupted.
InterruptedException - if the current thread is interruptedThread.interrupt()
public void acquire(int permits)
throws InterruptedException
interrupted.
permits - the number of permits to acquire
InterruptedException - if the current thread is interrupted
IllegalArgumentException - if permits less than zero.Thread.interrupt()
public boolean tryAcquire(long timeout)
throws InterruptedException
interrupted.
timeout - the maximum time to wait for a permit
InterruptedException - if the current thread is interruptedThread.interrupt()
public boolean tryAcquire(int permits,
long timeout)
throws InterruptedException
interrupted.
permits - the number of permits to acquiretimeout - the maximum time to wait for the permits
InterruptedException - if the current thread is interrupted
IllegalArgumentException - if permits less than zero.Thread.interrupt()public int drainPermits()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||