使用 JVMTI 进行死锁检测
我想知道是否可以使用 JVMTI 动态检测 Java 中的死锁。有两个事件指示使用同步语句在监视器上执行的操作:
Monitor Contished Enter
当线程尝试进入另一个线程已获取的 Java 编程语言监视器时发送。
监控已输入的争用
当线程等待另一个线程释放后进入 Java 编程语言监视器时发送。
这意味着,使用 JVMTI 我只能看到那些已经锁定的监视器。我想重建一个等待图,但没有事件指示我,已获取一个锁,该锁不由任何线程持有。这是不可能的。
还有其他选择吗? Unix 上的 SIGQUIT 命令允许显示死锁的线程转储,这在 JVMTI 中似乎是不可能的。
I wonder whether 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够通过 JMX 获取此信息。
尝试
You should be able to get this information via JMX.
Try