Larry Barowski wrote on 29-Aug-06 15:38:
>> I wonder if there is a possibility to access the list of
>> locks/monitors and display them in Java, kind of similar
[quoted text clipped - 4 lines]
> Most debuggers do this. I don't think there is a way
> to do it from within a Java program though.
Thanks.
This occurred to me too, I wanted verify if I miss something.
The reason for this omission is not obvious to me,
finally we have a full knowledge of all granted Java
lacks and of all pending classes and threads in the JVM.
Thomas
ThomasH - 30 Aug 2006 03:09 GMT
ThomasH wrote on 29-Aug-06 16:25:
> Larry Barowski wrote on 29-Aug-06 15:38:
>>> I wonder if there is a possibility to access the list of
[quoted text clipped - 5 lines]
>> Most debuggers do this. I don't think there is a way
>> to do it from within a Java program though.
Actually, on Unix and Linux, if you run jdk 1.4 or later
with hotspot and issue "kill -3" against the Java process,
JVM will dump threads. Its not precisely what I need, but
it contains the information looked after...
> Thanks.
> This occurred to me too, I wanted verify if I miss something.
[quoted text clipped - 4 lines]
>
> Thomas
Babu Kalakrishnan - 30 Aug 2006 04:25 GMT
> ThomasH wrote on 29-Aug-06 16:25:
> > Larry Barowski wrote on 29-Aug-06 15:38:
[quoted text clipped - 11 lines]
> JVM will dump threads. Its not precisely what I need, but
> it contains the information looked after...
I believe a Ctrl-Break on the console does the same on Windows as well.
BK
Thomas Hawtin - 30 Aug 2006 13:35 GMT
>> ThomasH wrote on 29-Aug-06 16:25:
>>> Larry Barowski wrote on 29-Aug-06 15:38:
[quoted text clipped - 11 lines]
>
> I believe a Ctrl-Break on the console does the same on Windows as well.
Or ctrl-\ on Solaris or Linux. I believe from 1.5 jstack (and presumably
jconsole) will do it without requiring access to the process output.
From 1.6 a program can examine its own locks (without connecting to its
own debugging port) through java.lang.management. As an example, I wrote
some code to detect when java.awt.EventQueue.invokeAndWait is called
with a lock held:
http://jroller.com/page/tackline?entry=detecting_invokeandwait_abuse
IIRC in 1.5 you will only get details of intrinsic locks. From 1.6 you
will also get details from java.utiil.concurrency.locks.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
ThomasH - 30 Aug 2006 21:42 GMT
Thomas Hawtin wrote on 30-Aug-06 05:36:
>>> ThomasH wrote on 29-Aug-06 16:25:
[...]
>>> Actually, on Unix and Linux, if you run jdk 1.4 or later
>>> with hotspot and issue "kill -3" against the Java process,
[quoted text clipped - 12 lines]
>
> http://jroller.com/page/tackline?entry=detecting_invokeandwait_abuse
Very nice idea, thanks!
> IIRC in 1.5 you will only get details of intrinsic locks. From 1.6 you
> will also get details from java.utiil.concurrency.locks.
>
> Tom Hawtin