|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.libxjava.concurrent.Semaphore
public final class Semaphore
Implementation of an "unfair" semaphore.
| Constructor Summary | |
|---|---|
Semaphore(int permits)
Constructor for a Semaphore. |
|
| Method Summary | |
|---|---|
void |
acquire()
Blocks until a permit is available and acquires it. |
void |
acquire(int permits)
Blocks until permits permits are available and acquires them. |
void |
acquireInterruptibly()
Blocks until a permit is available and acquires it. |
void |
acquireInterruptibly(int permits)
Blocks until permits permits are available and acquires them. |
int |
getPermits()
|
void |
release()
Releases a permit. |
void |
release(int permits)
Releases permits permits. |
boolean |
tryAcquire()
Tries to acquire a permit and returns immediately. |
boolean |
tryAcquire(int permits)
Tries to acquire permits permits and returns immediately. |
| 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 amount of permits| Method Detail |
|---|
public void acquire()
Same as acquire(1);
acquireInterruptibly()public void acquire(int permits)
permits permits are available and acquires them. A call
to this method is not interruptible!
acquireInterruptibly()
public void acquireInterruptibly()
throws InterruptedException
InterruptedException will
be thrown.
Same as acquireInterruptibly(1);
InterruptedExceptionacquire()
public void acquireInterruptibly(int permits)
throws InterruptedException,
IllegalArgumentException
permits permits are available and acquires them. If this
thread is interrupted an InterruptedException will
be thrown.
InterruptedException
IllegalArgumentExceptionacquire()public void release()
Same as release(1);
public void release(int permits)
permits permits. If other threads are waiting they get
notified.
public boolean tryAcquire()
Same as tryAcquire(1);
true if acquisition was successful and false otherwise.public boolean tryAcquire(int permits)
permits permits and returns immediately.
true if acquisition was successful and false otherwise.public int getPermits()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||