I perhaps was not clear enough in this question
https://stackoverflow.com/questions/62958507/how-to-have-intellij-play-just-the-thread-i-am-debugging-like-eclipse-does
so it was marked as duplicate of
switching between threads in Intellij Idea
but I did that and changed my breakpoint suspend policy to 'Thread'. This did not change the behavior at all so I am providing code now here.
Here is my code for this test
public class TestDebugger {
private static final Logger log = LoggerFactory.getLogger(TestDebugger.class);
private Executor exec = Executors.newFixedThreadPool(5);
public static void main(String[] args) throws InterruptedException {
new TestDebugger().start();
Thread.sleep(10000000);
}
private void start() {
Runnable r = new Runnable() {
@Override
public void run() {
log.info("logger BREAKPOINT A thread="+Thread.currentThread().getName());
log.info("logger A");
log.info("logger A");
log.info("logger A");
log.info("logger A");
log.info("logger A");
log.info("logger A");
log.info("logger BREAKPOINT B"+Thread.currentThread().getName());
}
};
exec.execute(r);
exec.execute(r);
exec.execute(r);
}
}
I start up the program and threads 1,2,3 all stop on breakpoint A. This part is good. Then I hit the play button while on thread 1 and behind my back, it switches threads!!! This is very annoying and not desired. In fact, I feel the eclipse debugger here works MUCH better as that is the default behavior.
In fact, if I hit play 6 times for all 3 threads, this is the logs...
NOTE: If I remove the other log statements in the middle, it starts working again as I would expect.......weird
INFO: logger BREAKPOINT A thread=pool-2-thread-1
INFO: logger BREAKPOINT A thread=pool-2-thread-3
INFO: logger BREAKPOINT Bpool-2-thread-3
INFO: logger BREAKPOINT Bpool-2-thread-1
INFO: logger BREAKPOINT A thread=pool-2-thread-2
INFO: logger BREAKPOINT Bpool-2-thread-2
The first TWO logs should both be thread 1 but instead it's thread 1, then thread 3....grrrr. Anyway to get this to work?
thanks, Dean