|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.runtime.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. However, no actual permit objects are used; the Semaphore
just keeps a count of the number available and acts accordingly.
Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource.
Note that JDK 1.5 contains a Semaphore class. We should obsolete this class when we upgrade.
Field Summary | |
---|---|
private int |
count
|
private static boolean |
verbose
|
Constructor Summary | |
---|---|
Semaphore(int count)
Creates a Semaphore with the given number of permits. |
Method Summary | |
---|---|
void |
acquire()
Acquires a permit from this semaphore, blocking until one is available. |
void |
release()
Releases a permit, returning it to the semaphore. |
boolean |
tryAcquire(long timeoutMillisec)
Acquires a permit from this semaphore, if one becomes available within the given waiting time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean verbose
private int count
Constructor Detail |
---|
public Semaphore(int count)
Method Detail |
---|
public void acquire()
public boolean tryAcquire(long timeoutMillisec)
If timeoutMillisec is less than or equal to zero, does not wait at all.
public void release()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |