开发者

Deadlock detection with JVMTI

开发者 https://www.devze.com 2023-03-10 10:45 出处:网络
I wonder whethe开发者_如何学Gor it is possible to detect deadlocks dynamically in Java by using the JVMTI. There are two events indicating actions on monitors using the synchronized statement:

I wonder whethe开发者_如何学Gor it is possible to detect deadlocks dynamically in Java by using the JVMTI. There are two events indicating actions on monitors using the synchronized statement:

Monitor Contended Enter

Sent when a thread is attempting to enter a Java programming language monitor already acquired by another thread.

Monitor Contended Entered

Sent when a thread enters a Java programming language monitor after waiting for it to be released by another thread.

This means, with JVMTI I can only see those monitors which are already locked. I wanted to reconstruct a wait-for graph, but without events indicating me, that a lock was acquired which is not held by any thread. This is impossible.

Are there alternatives? The SIGQUIT command on Unix allows a thread dump which displays the deadlocks, it seems like this is not possible within JVMTI.


You should be able to get this information via JMX.

Try

ManagementFactory.getThreadMXBean().findMonitorDeadlockedThreads();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号