14

Is there any mechanism within the Eclipse debugging environment to see the state of synchronization locks held and processes waiting?

2
  • Are you debugging a possible dead-lock? Commented May 3, 2010 at 9:34
  • I found an unexpected deadlock, but I had to "guess" that might be the case from the set of inexplicably stalled processes. There ought to be a better way. Commented May 3, 2010 at 10:00

3 Answers 3

13

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. I can't imagine why the monitors view is off by default.
It may be, that this only works if you are looking for a deadlock caused by a synchronized statement. I'm currently looking for one caused by an ReentrantReadWriteLock and I don't get this kind of information form eclipse.
the link is broken, eclipsezone.com doesn't seem to exist anymore
@TMG I've updated the answer with a link to the Internet Archive cached version. I don't know if the article is already outdated now or not, it's quite old.
I'm also not sure if I'm allowed to copy-paste the contents into my answer or not...
1

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.