Breakpoint Question on a multi-threaded program


I am using Intellij 9.0.3 under Windows XP and have actually been experiencing the same breakpoint issue since Intellij 7 and various versions of JDK. I've looked online and surprisingly couldn't find any discussion on this issue. So maybe I am missing something here?

The issue is that when I have multiple threads running in parallel on a normal J2SE program, only the breakpoints on the currently selected thread (the thread I am stepping through) will pause the program execution. On the other threads, the debugger never stops the execution at any breakpoints.

However, if I am not stepping through the code when the execution hits the breakpoint on the other thread (for example, if I resume the current thread at the line I spawn the other threads), then the debugger will work as expected and stop at the breakpoints on the other threads.

Based on the the observation described above, does it mean the Intellij debugger will not be able to pause more than 1 thread at any single time? In Eclipse, the debugger will pause multiple threads. I am able to switch back and forth different threads and step through the code on the selected thread while having the other threads paused there. Is Intellij capable doing the same thing? This seems to be something really basic, I tend to believe I am missing something here, rather than thinking it as a bug or an unsupported feature. Can anybody help me out on this?

P.S. I've set the "Suspend policy" to all on the BreakPoint menu, so I believe this is not a setting issue.


Comment actions Permalink

A typo on my post above, I am actually on Intellij IDEA Community Edition 9.0.4, not 9.0.3.

This issue may mislead programmers to a wrong direction. When the debugger doesn't stop the execution on breakpoints, it implies that the code with breakpoints added to it is never executed in the program. In fact, this is not true and the code may have been executed on a separate thread without stopping at the breakpoints. This false conclusion will probably waste you more time than you needed to resolve a bug.


Comment actions Permalink

I'm not sure if I understand your question correctly, but you can right click on a breakpoint. Select "Properties" and then you can select the suspend policy (All Threads, Current Thread, None). All Threads suspends all threads when the breakpoint is reached, Current Thread only the thread that reaches the breakpoint and None doesn't suspend execution. You can change the default behavior there as well.


Comment actions Permalink

The problem is when one thread is suspended, the other threads won't be suspended on breakpoints even though "Suspend All" option has been selected.

I don't believe this is the expected behaviour of Intellij IDEA, but I have no idea what could have gone wrong here.

I can replicate this on different program under different machines. It's been a problem to me since Intellij IDEA 7.

Comment actions Permalink

Hi Joseph,
I've an Intellij IDEA 9, I think that the multi-thread debug doesn't work with "ALL" suspend policy of breakpoint property,
but if you set the suspend policy to "THREAD" it should work.

You can see the guide on Suspend Policy section:

All When the breakpoint is hit, all threads are suspended.
Thread When the breakpoint is hit, the thread where the breakpoint is                  hit is suspended.
None No thread is suspended.


Please sign in to leave a comment.