|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.knowgate.multithreating.Semaphore
public final class Semaphore
Classical Dijkstra semaphore with wait() and
signal() operations.
| Field Summary | |
|---|---|
protected int |
counter
|
| Constructor Summary | |
|---|---|
Semaphore()
Create semaphore with zero counter value. |
|
Semaphore(int initValue)
Create semaphore with specified non-negative counter value. |
|
| Method Summary | |
|---|---|
void |
signal()
Increment value of the counter. |
void |
waitSemaphore()
Wait for non-zero value of counter. |
boolean |
waitSemaphore(long timeout)
Wait at most timeout miliseconds for non-zero value
of counter. |
| 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()
public Semaphore(int initValue)
initValue - initial value of semaphore counter| Method Detail |
|---|
public void waitSemaphore()
throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean waitSemaphore(long timeout)
throws java.lang.InterruptedException
timeout miliseconds for non-zero value
of counter.
timeout - the maximum time to wait in milliseconds.
true if counter is not zero, false
if wait() was terminated due to timeout expiration.
java.lang.InterruptedExceptionpublic void signal()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||