ibis.util
Class ConditionVariable

java.lang.Object
  extended byibis.util.ConditionVariable

public final class ConditionVariable
extends java.lang.Object

Condition variable synchronization construct. Condition variables are part of thread synchronization primitives of the Monitor construct. Threads can wait on a condition variable, and condition variables can be signalled by other threads to wake up one waiting thread. A bcast call wakes up all waiting threads on a ConditionVariable. A thread that calls cv_wait, cv_signal or cv_bcast must have locked the Monitor that owns this ConditionVariable. Condition Variables can be interruptible. For interruptible Condition Variables, Thread.interrupting the Thread that is waiting on this Condition Variable causes the waiting thread to return with an InterruptedException. Non-interruptible Condition Variables ignore Thread.interrupt. A Condition variable is created by means of the Monitor.createCV() or the Monitor.createCV(boolean) method.


Method Summary
 void cv_bcast()
          Signals all threads that are waiting on this condition variable.
 void cv_signal()
          Signals a single thread that is waiting on this condition variable.
 void cv_wait()
          Waits until the thread is signalled (by means of cv_signal() or cv_bcast()).
 boolean cv_wait(long timeout)
          Waits until the thread is signalled (by means of cv_signal() or cv_bcast()), or the specified timeout expires.
static void report(java.io.PrintStream out)
          When statistics are enabled, prints them on the specified stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cv_wait

public final void cv_wait()
                   throws java.lang.InterruptedException
Waits until the thread is signalled (by means of cv_signal() or cv_bcast()).

Throws:
java.lang.InterruptedException - is thrown when the condition variable was created with interrupts enabled, and Thread.interrupt() was invoked on the current thread.

cv_wait

public final boolean cv_wait(long timeout)
                      throws java.lang.InterruptedException
Waits until the thread is signalled (by means of cv_signal() or cv_bcast()), or the specified timeout expires.

Parameters:
timeout - the specified timeout.
Returns:
true when this method returns because the timeout expired.
Throws:
java.lang.InterruptedException - is thrown when the condition variable was created with interrupts enabled, and Thread.interrupt() was invoked on the current thread.

cv_signal

public final void cv_signal()
Signals a single thread that is waiting on this condition variable.


cv_bcast

public final void cv_bcast()
Signals all threads that are waiting on this condition variable.


report

public static void report(java.io.PrintStream out)
When statistics are enabled, prints them on the specified stream.

Parameters:
out - the stream to print on.


The Ibis project