Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse & other Java IDEs for debugging concurrent code

I'm currently working on some concurrent code that would appear to have a few race conditions in it. I'm attempting to debug the code using my current IDE, Eclipse, but I'm not completely satisfied. In particular, a race condition is present for a variable such that without a break point on one of the methods accessing it (the one 'getting' it), the variable setting method does not complete, and the variable is set to null. However, if I put a break point on the accessing method, and hold F8--the default step over button--the variable is almost always set to the correct (non-null) value.

This leads me to ask the following: is it possible that Eclipse doesn't pause execution on the breakpoint across all threads quickly enough that I can look at the potential race condition as it appears without a break point, or is something else (probably) happening?

If it is the case that Eclipse doesn't pause execution quickly, are there other IDEs/debuggers for Java that may do a better job of this? Note that I'm not looking for formal verification tools like Java Pathfinder--I don't want to check if race conditions are present, I want to see them unfold in my debugger (if only because it might be interesting to watch).

like image 577
Jan Gorzny Avatar asked Jul 13 '10 19:07

Jan Gorzny


1 Answers

By default, Eclipse will not suspend other threads if your break point is reached by one thread. However, you can change this behaviour in Window > Preferences > Java > Debug > Default suspend policy for new breakpoints => 'Suspend VM'.

like image 163
Bachi Avatar answered Sep 22 '22 06:09

Bachi