|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.jagrlib.Semaphore
public class Semaphore
General semaphore for inter-thread synchronization.
Field Summary | |
---|---|
protected int |
counter
Number of waiting clients (<0) or number of free signals (>0). |
Constructor Summary | |
---|---|
Semaphore(int limit)
Initializing constructor. |
Method Summary | |
---|---|
int |
getSignalCount()
Returns number of signals available. |
void |
semSignal(int number)
Signals the number of times. |
void |
semSignalAll(int limit)
Resume all waiting threads (at most limit ones). |
boolean |
semWait()
Waits for one signal. |
boolean |
semWait(long millis)
Waits for one signal for the restricted amount of time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int counter
Constructor Detail |
---|
public Semaphore(int limit)
limit
- Initial number of free signals (should be >= 0)Method Detail |
---|
public boolean semWait()
semWait(long)
public boolean semWait(long millis)
millis
- Number of milliseconds to wait (0L => wait forever).
semWait()
public void semSignal(int number)
number
- Number of signals to be generated.semSignalAll(int)
public void semSignalAll(int limit)
limit
- Maximum number of waiting threads to be resumed (for <= 0 resumes exactly
all currently waiting threads).semSignal(int)
public int getSignalCount()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |