Possible to show java.util.concurrent locks in Debug view? [message #649046] |
Mon, 17 January 2011 07:27  |
Eclipse User |
|
|
|
Hi,
the Java debug view can show the locks a thread has or is waiting for but this only works for locks set with synchronized keyword.
Am I missing an option to show locks set with for example with a java.util.concurrent.ReentrantLock? If I do a thread dump in VisualVM that information is available.
I could not find an existing feature request in the bug database so I could make one it it's not a available.
import java.util.concurrent.locks.ReentrantLock;
public class TestLockDebug {
public static void main(String[] args) {
Object lock1 = new Object();
ReentrantLock lock2 = new ReentrantLock();
try {
lock2.lock();
synchronized (lock1) {
try {
Thread.sleep(100000);
}
catch (InterruptedException ignore) {
}
}
}
finally {
lock2.unlock();
}
}
}
Using JDK 6u23:
Eclipse Helios Release Build id: 20100617-1415:
Thread [main] (Suspended)
owns: Object (id=15)
Thread.sleep(long) line: not available [native method]
TestLockDebug.main(String[]) line: 13
VisualVM 1.3.1 thread dump:
"main" prio=6 tid=0x003b8400 nid=0x1120 waiting on condition [0x0090f000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at TestLockDebug.main(TestLockDebug.java:13)
- locked <0x02e60c30> (a java.lang.Object)
Locked ownable synchronizers:
- <0x02e6c600> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03168 seconds