Intellij idea 在intellij 2020.1中,当我在调试器中点击play时,如何阻止它切换线程?(不重复)
在这个问题上,我可能不够清楚Intellij idea 在intellij 2020.1中,当我在调试器中点击play时,如何阻止它切换线程?(不重复),intellij-idea,intellij-2020,Intellij Idea,Intellij 2020,在这个问题上,我可能不够清楚 https://stackoverflow.com/questions/62958507/how-to-have-intellij-play-just-the-thread-i-am-debugging-like-eclipse-does 所以它被标记为 但我这样做了,并将断点挂起策略更改为“线程”。这根本没有改变行为,所以我现在在这里提供代码 这是我的测试代码 public class TestDebugger { private static fin
https://stackoverflow.com/questions/62958507/how-to-have-intellij-play-just-the-thread-i-am-debugging-like-eclipse-does
所以它被标记为
但我这样做了,并将断点挂起策略更改为“线程”。这根本没有改变行为,所以我现在在这里提供代码
这是我的测试代码
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);
}
}
我启动程序,线程1、2、3都在断点A处停止。这部分很好。然后我在线程1上点击播放按钮,在我背后,它切换线程!!!这是非常烦人和不希望的。事实上,我觉得这里的eclipse调试器工作得更好,因为这是默认行为
事实上,如果我对所有3个线程都按play 6次,这就是日志
<强>注释:如果我在中间删除其他日志语句,它会像我预期的那样重新开始工作……怪异< /强>
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
前两个日志都应该是线程1,但它应该是线程1,然后是线程3….grrrr。不管怎样,要让它发挥作用
谢谢,
迪恩这种行为是故意的,目前无法改变。资料来源:负责IntelliJ IDEA调试器的开发人员。!