United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6215270 : API to detect all monitors locked/waited-on by any given thread

Details
Type:
Enhancement
Submit Date:
2005-01-07
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2005-06-14
Component:
core-svc
OS:
windows_xp
Sub-Component:
java.lang.management
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2,5.0
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
A DESCRIPTION OF THE REQUEST :
Issue #4593133 is supposed to include this RFE and it was recently closed as fixed, however it was *not* completely fixed. The entire point of programmatically getting thread-dumps is so we can detect deadlocks, yet the RFE was fixed without providing this functionality. So I will ask explicitly:

We require an API such that the thread-dump API provides us a way to get the list of all monitors locked by a given thread and/or the monitors it is waiting on. The point here is that until we can programmatically reproduce the exact same thread-dump output as produced by the JVM when we hit CTRL-C, this issue won't be closed.

JUSTIFICATION :
Need to be able to programmatically manipulate thread-dump output. Among other things, I personally need it to produce and manipulate thread-dumps in remote process-spaces.
###@###.### 2005-1-07 21:13:32 GMT

                                    

Comments
EVALUATION

The 5.0 java.lang.management API provides the deadlock detection support.
See ThreadMXBean.findMonitorDeadlockedThreads() and ThreadInfo class.
You can find out which monitor a thread is blocked to enter or waiting on.

Regarding the request for getting all monitors locked by a given thread,
the current Java Debugging Interface (JDI) provides the API to get the list
of object monitors owned by a given thread (see com.sun.jdi.ThreadReference.ownedMonitors method).  However, this information
is not necessary for detecting deadlocks.

One information that control-break output provides but missing in ThreadInfo is where (which stack frame) a monitor is locked which will help debugging when deadlock is detected.  The JDI interface doesn't provide such information either. I consider this as a duplicate of 5052099 and will close it as a dup.

###@###.### 2005-1-10 22:45:40 GMT

Providing information about the stack frame that an object monitor was locked is very useful for troubleshooting.  We will add a few APIs in java.lang.management in Mustang so that you can find the list of all object monitors currently locked by individual threads.  You can find out which stack frame locked each object monitor.

See java.lang.management.ThreadMXBean.getAllLockedMonitors and the new MonitorInfo class.  This change will be available in B39 Mustang Snapshot Release.

See also 5086470 for the monitoring support of java.util.concurrent locks.
###@###.### 2005-05-20 23:07:15 GMT
                                     
2005-01-10



Hardware and Software, Engineered to Work Together