org.jlog2.util
Class Monitor

java.lang.Object
  extended by org.jlog2.util.Monitor

public class Monitor
extends java.lang.Object

To synchronize threads on.


Field Summary
protected static java.lang.Object syncOn
          An object to synchronize on
protected static Monitor theMonitor
          The variable to synchronize on
 
Method Summary
static Monitor getMonitor()
          Return the monitor instance.
 java.lang.Object getSyncOn()
          Get an object to synchronize on.
 void lock()
          Lock current thread on this monitor.
 void release()
          Release locked threads.
static void restartThread(java.lang.Thread theThread, boolean startNew)
          Re-start the thread running depending on its current state.
static void stopThread(java.lang.Thread theThread)
          Re-start the thread running depending on its current state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

syncOn

protected static final java.lang.Object syncOn
An object to synchronize on


theMonitor

protected static final Monitor theMonitor
The variable to synchronize on

Method Detail

getMonitor

public static Monitor getMonitor()
Return the monitor instance.

Returns:
the value of theMonitor.

getSyncOn

public java.lang.Object getSyncOn()
Get an object to synchronize on.

Returns:
the value of syncOn.

lock

public void lock()
Lock current thread on this monitor.


release

public void release()
Release locked threads.


stopThread

public static void stopThread(java.lang.Thread theThread)
Re-start the thread running depending on its current state.

Parameters:
theThread - the thread to stop.

restartThread

public static void restartThread(java.lang.Thread theThread,
                                 boolean startNew)
Re-start the thread running depending on its current state.

Parameters:
theThread - the thread to start.
startNew - true if start a new thread for the first time.