Reputation: 30097
By default, Eclipse breakpoints are suspending only one thread. This causes application continues to run when I am thinking on breakpoint.
The is another mode for breakpoint - to suspend entire VM. This stops all thread but apparently I am unable to resume an execution or execution behaves differently on resume.
Is it possible to do normal suspend on breakpoints in Eclipse?
UPDATE
There is definitely not my problem, but Eclipse/JVM/other human bug. I made a simple example without any thread interaction:
package tests;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Try_EclipseMultithreadedBreakpoint {
private static final Logger log = LoggerFactory.getLogger(Try_EclipseMultithreadedBreakpoint.class);
public static class Thread1 extends Thread {
public Thread1() {
setName("Thread1");
}
@Override
public void run() {
for(int i=0; i<10; ++i) {
log.info("tick {}", i);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
}
}
}
}
public static class Thread2 extends Thread {
public Thread2() {
setName("Thread2");
}
@Override
public void run() {
for(int i=0; i<15; ++i) {
log.info("tick {}", i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}
public static void main(String[] args) {
new Thread1().start();
new Thread2().start();
}
}
then I put an exception into second thread (Thread2):
then I have few breakpoint hits and resumes, then removed breakpoint and resumed, and application hanged.
Below is it's hung state:
as you see by output, thread 1 was not resumed. It printed only one tick and stopped. And it is not waiting for some monitor as reported by Eclipse, it is suspended.
Note, that I didn't set any breakpoints in thread 1, I set them only in thread 2.
Simultaneously, some "Finalizer" thread is waiting for some internal resource.
Also, I noticed, that after breakpoint hit, I was required to press resume several times before it actually resumed.
Upvotes: 1
Views: 3667