ch.aplu.util
Class Monitor

java.lang.Object
  extended by ch.aplu.util.Monitor

public class Monitor
extends java.lang.Object

Helper class for wait-notify mechanism.


Method Summary
static boolean putSleep()
          Same as putSleep(int timeout) with timeout = 0 (timeout disabled).
static boolean putSleep(int timeout)
          Same as putSleep(Object monitor, int timeout), but uses internal static monitor object.
static boolean putSleep(java.lang.Object monitor)
          Same as putSleep(Object monitor, int timeout) with timeout = 0 (timeout disabled).
static boolean putSleep(java.lang.Object monitor, int timeout)
          Put the current thread in a wait state until wakeUp() is called or timeout ( in ms ) expires.
static void wakeUp()
          Wake up all threads waiting for the internal static monitor lock.
static void wakeUp(java.lang.Object monitor)
          Wake up all threads waiting for the given object's lock.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

putSleep

public static boolean putSleep(int timeout)
Same as putSleep(Object monitor, int timeout), but uses internal static monitor object.


putSleep

public static boolean putSleep(java.lang.Object monitor,
                               int timeout)
Put the current thread in a wait state until wakeUp() is called or timeout ( in ms ) expires. If timeout <= 0 the method blocks infinitely until wakeUp() is called. More than one thread may be in the wait state, calling wakeUp() will release one by one.
Return values:
true: wakeUp was called before timeout expired ("no timeout occured")
false: timeout expired before wakeUp was called ("timeout occured")


putSleep

public static boolean putSleep(java.lang.Object monitor)
Same as putSleep(Object monitor, int timeout) with timeout = 0 (timeout disabled).


putSleep

public static boolean putSleep()
Same as putSleep(int timeout) with timeout = 0 (timeout disabled).


wakeUp

public static void wakeUp(java.lang.Object monitor)
Wake up all threads waiting for the given object's lock.


wakeUp

public static void wakeUp()
Wake up all threads waiting for the internal static monitor lock.