multithreading - intellij-不在多线程代码中的所有断点上停止

标签 multithreading intellij-idea breakpoints

我正在尝试使用断点运行以下代码,如下所示:

    new Thread(new Runnable() {
        @Override
        public void run() {
            System.out.println("Starting"); //breakpoint here
        }
    }).start();

    int i = 10;
    i++; //breakpoint here

当此代码仅运行时,将击中i++断点...如果我删除了该断点,则将正确命中另一个线程的断点。为什么会发生这种奇怪的行为?

最佳答案

记录在http://www.jetbrains.com/idea/webhelp/breakpoints-2.html中:

There are certain cases when IntelliJ IDEA will not stop at a breakpoint. Consider the following situation: Two breakpoints are set at the different methods of a class, and there suspend policy is set to All. When one of the breakpoints is hit, some step actions are performed. If at the time of stepping another thread hits the second breakpoint, IntelliJ IDEA will not stop there.



我复制了您的代码示例并重新创建了这种情况。
确实,如文档中所述,在i++断点处停止后,如果我按F8键(跨步),则程序不会在另一个断点处停止。但是,如果我按F9键(恢复),则程序会使在另一个断点处再次停止。

关于multithreading - intellij-不在多线程代码中的所有断点上停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15298662/

相关文章:

java - 单核和多核上的线程执行

c - c中的pthread条件等待

intellij-idea - 如何在 IntelliJ 中的开发人员之间共享代码样式设置

java - IntelliJ IDEA 检查器不再适用于 github 项目?

breakpoints - 无法在 Firefox Developer Edition (FDE) 的调试器 Pane 中设置断点

c++ - XCode 不会破坏 #include 的 CPP 文件

multithreading - 术语问题: mutex lock,自旋锁,可 sleep 锁

c++ - 超时后在哪里销毁thread和deadline_timer对象?

jakarta-ee - IntelliJ 中的基本新 RESTful 项目无法运行,注释扫描失败?

xcode - 从 Xcode 断点运行 shell 命令