|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.deploymentadmin.Semaphore
public class Semaphore
A semaphore, that maintains one single permit. An acquire()
blocks until a permit is
available, whilst release()
will unblock it.
Constructor Summary | |
---|---|
Semaphore()
Creates a new semaphore that is available. |
|
Semaphore(boolean isAvailable)
Creates a new semaphore and allows you to specify if it's available or not. |
Method Summary | |
---|---|
void |
acquire()
Acquires the semaphore, or blocks until it's available or the thread is interrupted. |
void |
release()
Releases the semaphore. |
boolean |
tryAcquire(long timeout)
Tries to acquire the semaphore and waits for the duration of the specified timeout until it becomes available. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Semaphore()
public Semaphore(boolean isAvailable)
isAvailable
- should the semaphore be available or notMethod Detail |
---|
public void acquire() throws InterruptedException
InterruptedException
- when the thread is interruptedpublic boolean tryAcquire(long timeout) throws InterruptedException
timeout
- the number of milliseconds to wait
true
if the semaphore was acquired, false
if it was
not after waiting for the specified amount of time
InterruptedException
- when the thread is interruptedpublic void release()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |