| |
|
| java.lang.Object com.knowgate.multithreating.Semaphore
Semaphore | final public class Semaphore (Code) | | Classical Dijkstra semaphore with wait() and
signal() operations.
author: Konstantin Knizhnik version: 1.04 |
Constructor Summary | |
public | Semaphore() Create semaphore with zero counter value. | public | Semaphore(int initValue) Create semaphore with specified non-negative counter value. |
Method Summary | |
public synchronized void | signal() Increment value of the counter. | public synchronized void | waitSemaphore() Wait for non-zero value of counter. | public synchronized boolean | waitSemaphore(long timeout) Wait at most timeout miliseconds for non-zero value
of counter.
Parameters: timeout - the maximum time to wait in milliseconds. |
counter | protected int counter(Code) | | |
Semaphore | public Semaphore()(Code) | | Create semaphore with zero counter value.
|
Semaphore | public Semaphore(int initValue)(Code) | | Create semaphore with specified non-negative counter value.
Parameters: initValue - initial value of semaphore counter |
signal | public synchronized void signal()(Code) | | Increment value of the counter. If there are waiting threads, exactly
one of them will be awaken.
|
waitSemaphore | public synchronized boolean waitSemaphore(long timeout) throws InterruptedException(Code) | | Wait at most timeout miliseconds for non-zero value
of counter.
Parameters: timeout - the maximum time to wait in milliseconds. true if counter is not zero, false if wait() was terminated due to timeout expiration. |
|
|
|