开发者

debugging Java synchronization

开发者 https://www.devze.com 2022-12-29 13:06 出处:网络
开发者_如何学编程Is there any mechanism within the Eclipse debugging environment to see the state of synchronization locks held and processes waiting?You can show the state of object monitors in Eclip

开发者_如何学编程Is there any mechanism within the Eclipse debugging environment to see the state of synchronization locks held and processes waiting?


You can show the state of object monitors in Eclipse's debugger. You can find a short, clear tutorial here. For each thread, Eclipse can show you the monitors the thread owns and those it is waiting for.

Update 2020-01-20: The link above no longer works. Here's a link to cached version on the Internet Archive.


As suggested here you could (if you run the Sun JVM) perform the following steps:

  1. launch jconsole or jvisualvm (both present in the bin-directory of your JDK-installation,
  2. attach to the process you suspect has locked up
  3. go to the Threads pane. There is a "Detect Deadlock" button


Another option: I would suggest add logging in order to "debug" your code. Sometimes it will be more intuitive.

0

精彩评论

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