net.sf.jauvm
Class Monitor

java.lang.Object
  extended by net.sf.jauvm.Monitor

public class Monitor
extends Object

Contains methods used to synchronize access to objects.


Constructor Summary
protected Monitor()
           
 
Method Summary
static void enter(Object obj)
          Acquires the monitor for an object.
static void exit(Object obj)
          Releases the monitor for an object.
static void notify(Object obj)
          Notifies a single thread that is waiting on an object's monitor.
static void notifyAll(Object obj)
          Notifies all threads that are waiting on an object's monitor.
static void wait(Object obj)
          Waits to be notified on an object.
static void wait(Object obj, long timeout, TimeUnit unit)
          Waits to be notified on an object or until a specified amount of of time elapses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Monitor

protected Monitor()
Method Detail

enter

public static void enter(Object obj)
Acquires the monitor for an object.

Calling this method on a given object is equivalent to entering a synchronized block that protects that object.

Note: this method is currently not implemented, and as such always throws the UnsupportedOperationException. See the java.util.concurrent.locks package for alternative synchronization mechanisms.

Parameters:
obj - the object on which to acquire the monitor lock
Throws:
NullPointerException - if obj is null
UnsupportedOperationException - if this operation is not supported by the current JVM
See Also:
java.util.concurrent.locks

exit

public static void exit(Object obj)
Releases the monitor for an object.

Calling this method on a given object is equivalent to exiting a synchronized block that protects that object.

Note: this method is currently not implemented, and as such always throws the UnsupportedOperationException. See the java.util.concurrent.locks package for alternative synchronization mechanisms.

Parameters:
obj - the object on which to acquire the monitor lock
Throws:
NullPointerException - if obj is null
IllegalMonitorStateException - if the current thread does not hold the lock on obj
UnsupportedOperationException - if this operation is not supported by the current JVM
See Also:
java.util.concurrent.locks

notify

public static void notify(Object obj)
Notifies a single thread that is waiting on an object's monitor.

Calling this method on a given object is equivalent calling that object's notify() method.

Parameters:
obj - the object a thread is waiting for
See Also:
Object.notify()

notifyAll

public static void notifyAll(Object obj)
Notifies all threads that are waiting on an object's monitor.

Calling this method on a given object is equivalent calling that object's notifyAll() method.

Parameters:
obj - the object threads are waiting for
See Also:
Object.notifyAll()

wait

public static void wait(Object obj)
                 throws InterruptedException
Waits to be notified on an object. monitor.

Calling this method on a given object is equivalent calling that object's wait() method.

Parameters:
obj - the object on which to wait
Throws:
InterruptedException
See Also:
Object.wait()

wait

public static void wait(Object obj,
                        long timeout,
                        TimeUnit unit)
                 throws InterruptedException
Waits to be notified on an object or until a specified amount of of time elapses.

Calling this method on a given object is equivalent calling unit.timedWait(obj, time).

Parameters:
obj - the object on which to wait
timeout - the maximum time to wait
unit - the time util of timeout
Throws:
InterruptedException
See Also:
TimeUnit.timedWait(Object, long)