common-util

local.tomas.util.sync
Class Condition

java.lang.Object
  extended by local.tomas.util.sync.Condition

public class Condition
extends Object

A Condition is used to exchange the state of a boolean condition between threads. A Mutex is used for synchronization. This mutex can be either passed to the constructor or a default one created internally.

Version:
1.0
Author:
Tomas Teubner
See Also:
Mutex

Constructor Summary
Condition()
          Construct condition with internal mutex.
Condition(Mutex mutex)
          Construct condition with specific mutex.
 
Method Summary
 void conditionNotify()
          Notify condition has been met.
 void conditionNotifyAll()
          Notify all threads that condition has been met.
 void conditionWait()
          Wait until condition has been met.
 void lock()
           
 boolean trylock()
           
 void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition

public Condition(Mutex mutex)
Construct condition with specific mutex.

Parameters:
mutex - the mutex

Condition

public Condition()
Construct condition with internal mutex.

Method Detail

conditionWait

public void conditionWait()
                   throws InterruptedException
Wait until condition has been met.

Throws:
InterruptedException

conditionNotify

public void conditionNotify()
Notify condition has been met. The first waiting thread will continue.


conditionNotifyAll

public void conditionNotifyAll()
Notify all threads that condition has been met. All waiting threads will continue.


lock

public void lock()
          throws InterruptedException
Throws:
InterruptedException

trylock

public boolean trylock()
                throws InterruptedException
Throws:
InterruptedException

unlock

public void unlock()

common-util

Copyright © 2005-2007 Tomas Teubner. All Rights Reserved.