|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.excalibur.concurrent.Semaphore
This class implements a counting semaphore, also known as a Dijkstra semaphore. A semaphore is used to control access to resources. A counting semaphore has a count associated with it and each acquire() call reduces the count. A thread that tries to acquire() a semaphore with a zero count blocks until someone else calls release(), which increases the count.
Constructor Summary | |
Semaphore(long tokens)
Deprecated. Creates a semaphore with the specified number of tokens, which determines the maximum number of acquisitions to allow. |
Method Summary | |
void |
acquire()
Deprecated. Aquire access to resource. |
boolean |
attempt(long msecs)
Deprecated. Aquire access to resource. |
void |
release()
Deprecated. Release lock. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Semaphore(long tokens)
tokens
- the maximum number of acquisitions to allowMethod Detail |
public void acquire() throws InterruptedException
Sync
acquire
in interface Sync
InterruptedException
- if an error occurspublic void release()
Sync
release
in interface Sync
public boolean attempt(long msecs) throws InterruptedException
Sync
attempt
in interface Sync
msecs
- the duration to wait for lock to be released
InterruptedException
- if an error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |