Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS

Class jsync.Semaphore

java.lang.Object
    |
    +----jsync.Semaphore

public class Semaphore
extends java.lang.Object
Classical Dijkstra semaphore with wait() and signal() operations.


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
 equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore()
Create semaphore with zero counter value.

Semaphore

public Semaphore(int initValue)
Create semaphore with specified non-negative counter value.
Parameters:
initValue - initial value of semaphore counter
Method Detail

waitSemaphore

public void waitSemaphore()
Wait for non-zero value of counter.

waitSemaphore

public boolean waitSemaphore(long timeout)
Wait at most timeout miliseconds for non-zero value of counter.
Parameters:
timeout - the maximum time to wait in milliseconds.
Returns:
true if counter is not zero, false if wait() was terminated due to timeout expiration.

signal

public void signal()
Increment value of the counter. If there are waiting threads, exactly one of them will be awaken.

Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS