| |
|
| java.lang.Object org.columba.core.base.Semaphore
Semaphore | final public class Semaphore (Code) | | A Semaphore class to be used by multiple threads that needs to be notified when a
thread has released this semaphore. Depending threads uses one of the
waitUntilReleased() method to wait for the semaphore, then when the Thread that
owns the Semaphore (called the hold() method) calls the release method all other
threads are awaken.
All threads that invoke waitUntilReleased() waits until a thread invokes the
release()
author: erma |
Method Summary | |
public void | hold() Holds this semaphores. | public boolean | isHolding() Returns if the semaphore holds all threads that invoke the waitUntilReleased()
methods. | public void | release() Release all threads that has invoked the waitUntilReleased(). | public void | waitUntilReleased() Waits the current thread until another thread invokes the relase() or
continues if another thread already has invoked the release(). | public void | waitUntilReleased(long timeout) Waits the current thread until another thread invokes the relase() or
continues if another thread already has invoked the release(). |
Semaphore | public Semaphore()(Code) | | Creates a new instance of Semaphore
|
Semaphore | public Semaphore(boolean isHolding)(Code) | | Creates a new instance of Semaphore
Parameters: isHolding - if the semaphore should hold all threads from the begining ornot. |
hold | public void hold()(Code) | | Holds this semaphores. Threads that call the waitUntilReleased stops until the
release() method is called.
See Also: Semaphore.release() |
isHolding | public boolean isHolding()(Code) | | Returns if the semaphore holds all threads that invoke the waitUntilReleased()
methods.
true or false |
release | public void release()(Code) | | Release all threads that has invoked the waitUntilReleased().
|
waitUntilReleased | public void waitUntilReleased() throws InterruptedException(Code) | | Waits the current thread until another thread invokes the relase() or
continues if another thread already has invoked the release(). This method
behaves exactly as if it simply performs the call waitUntilReleased(0).
throws: InterruptedException - if another thread has interrupted the currentthread. |
waitUntilReleased | public void waitUntilReleased(long timeout) throws InterruptedException(Code) | | Waits the current thread until another thread invokes the relase() or
continues if another thread already has invoked the release().
Parameters: timeout - the maximum time to wait in milliseconds. throws: InterruptedException - if another thread has interrupted the currentthread. |
|
|
|