javax.tools.diagnostics.runtime.java
Interface JavaMonitor


public interface JavaMonitor

Represents the underlying monitor used by a Java Virtual Machine to manage locking and synchronization of a Java object.

The underlying monitor is implementation specific. Some implementations may choose to use their monitor implementations to control access to Java Virtual Machine resources that are not objects. In such cases, getObject() will return null.

Java programmers use the synchronized modifier on methods and the synchronized block within methods to control simultaneous access to Java objects. Java uses monitors for this synchronization, which can be implemented using a variety of techniques. The JavaMonitor class presents the simple monitor abstraction that allows the caller to determine:

This API presents only what exists at the Java Virtual Machine bytecode level. The locking facilities provided by the java.util.concurrent.lock package are expected to be implemented on top of ordinary Java monitors.


Method Summary
 boolean equals(java.lang.Object obj)
           
 java.util.List<JavaThread> getEnterWaiters()
          Get the set of threads waiting to enter the monitor.
 ImagePointer getID()
          Get the identifier for this monitor.
 java.lang.String getName()
          Get the name of a monitor.
 java.util.List<JavaThread> getNotifyWaiters()
          Get the set of threads waiting to be notified on the monitor.
 JavaObject getObject()
          Get the object associated with this monitor.
 JavaThread getOwner()
          Get the thread which currently owns the monitor.
 int hashCode()
           
 

Method Detail

getObject

JavaObject getObject()

Get the object associated with this monitor. Not all JavaMonitors will have objects, as there may be JavaMonitors that are used to control access to internal Java Virtual Machine resources ("Raw" monitors).

Returns:
the Java object associated with this monitor, or null.

getName

java.lang.String getName()
                         throws CorruptDataException

Get the name of a monitor.

For monitors not associated with object ("raw" monitors), it is expected that this method will return a descriptive name that is meaningful to the Java Virtual Machine implementation. For example "Heap lock" might be a monitor controlling exclusive access to the Java heap.

For objects, the expectation is that the name will uniquely identify the object the monitor is associated with. This is not expected to necessarily be consistent between different dumps of the same JVM.

Returns:
the name of the monitor (never null)
Throws:
CorruptDataException

getOwner

JavaThread getOwner()
                    throws CorruptDataException

Get the thread which currently owns the monitor. This may be null if the monitor is not owned.

Returns:
the owner of the monitor, or null if the monitor is not owned
Throws:
CorruptDataException

getEnterWaiters

java.util.List<JavaThread> getEnterWaiters()

Get the set of threads waiting to enter the monitor.

The returned list follows the standard semantics for javax.tools.diagnostics collections.

The returned value is never null but can be an empty list.

Returns:
a list of threads waiting to enter this monitor
See Also:
JavaThread, CorruptData

getNotifyWaiters

java.util.List<JavaThread> getNotifyWaiters()

Get the set of threads waiting to be notified on the monitor. They are usually threads in the Object.wait() method.

The returned list follows the standard semantics for javax.tools.diagnostics collections.

The returned value is never null but can be an empty list.

Returns:
a list of threads waiting to be notified on this monitor.
See Also:
JavaThread, CorruptData

getID

ImagePointer getID()

Get the identifier for this monitor.

Returns:
The pointer which uniquely identifies this monitor in memory.

equals

boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
true if the given object refers to the same Java Monitor in the image

hashCode

int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2010. All Rights Reserved.