|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.excalibur.concurrent.DijkstraSemaphore
Also called counting semaphores, Djikstra semaphores are used to control access to a set of resources. A Djikstra semaphore has a count associated with it and each acquire() call reduces the count. A thread that tries to acquire() a Djikstra semaphore with a zero count blocks until someone else calls release() thus increasing the count.
Constructor Summary | |
DijkstraSemaphore(int maxCount)
Deprecated. Creates a Djikstra semaphore with the specified max count and initial count set to the max count (all resources released). |
|
DijkstraSemaphore(int maxCount,
int initialCount)
Deprecated. Creates a Djikstra semaphore with the specified max count and an initial count of acquire() operations that are assumed to have already been performed. |
Method Summary | |
void |
acquire()
Deprecated. If the count is non-zero, acquires a semaphore and decrements the count by 1, otherwise blocks until a release() is executed by some other thread. |
void |
acquireAll()
Deprecated. Tries to acquire all the semaphores thus bringing the count to zero. |
void |
release()
Deprecated. Releases a previously acquires semaphore and increments the count by one. |
void |
release(int count)
Deprecated. Same as release() except that the count is increased by pCount instead of 1. |
void |
releaseAll()
Deprecated. Releases all semaphores setting the count to max count. |
void |
starvationCheck()
Deprecated. This method blocks the calling thread until the count drops to zero. |
boolean |
tryAcquire()
Deprecated. Non-blocking version of acquire(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DijkstraSemaphore(int maxCount)
maxCount
- is the max semaphores that can be acquiredpublic DijkstraSemaphore(int maxCount, int initialCount)
maxCount
- is the max semaphores that can be acquiredinitialCount
- is the current count (setting it to zero means all
semaphores have already been acquired). 0 <= initialCount <= maxCountMethod Detail |
public void acquire() throws InterruptedException
InterruptedException
- is the thread is interrupted when blockedtryAcquire()
,
acquireAll()
public boolean tryAcquire()
public void release()
release( int count )
,
releaseAll()
public void release(int count)
count
- is the amount by which the counter should be incrementedrelease()
public void acquireAll() throws InterruptedException
InterruptedException
- if the thread is interrupted when blocked on
this callacquire()
,
releaseAll()
public void releaseAll()
acquireAll()
public void starvationCheck() throws InterruptedException
InterruptedException
- if the thread is interrupted while waiting
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |