gpt4 book ai didi

debugging - 为什么intellij想法不能立即终止调试过程?

转载 作者:行者123 更新时间:2023-12-04 04:10:19 25 4
gpt4 key购买 nike

我正在使用 idea 2016.1.1 ,想知道为什么当我单击停止按钮时,idea不会立即终止调试过程。

例如。使用这段代码来重现它

public class Main {

public static void main(String[] args) {
int i = 0;
while (true) {
i++;
System.out.print("I'm still alive: ");
System.out.println(i);
}
}
}

在循环开始之前设置一个断点。

enter image description here

启动调试 session ,等待其中断,然后按红色的停止按钮(CTRL-F2)。

enter image description here

,我希望该过程立即停止,并且它不会打印任何内容,但是会打印:
"C:\Program Files\Java\jdk1.6.0_38\bin\java" ....
Connected to the target VM, address: '127.0.0.1:54394', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:54394', transport: 'socket'
I'm still alive: 1
I'm still alive: 2
I'm still alive: 3
I'm still alive: 4
...
I'm still alive: 319
I'm still alive: 320
I'm still alive: 321
I'm still alive:
Process finished with exit code -1

为什么该过程没有立即停止?

还有另一种强制立即停止的方法吗?

编辑

刚刚尝试了 想法14.1.5 。该过程将按预期立即停止。似乎是在2016年引入了一个错误。

最佳答案

到目前为止,我的调查...

当IDEA启动Java进程时,它将使用主包装器。该包装器启动一个守护程序线程,该线程监听ServerSocket中的命令。

IDEA将STOP信号发送到该服务器套接字。当服务器线程接收到STOP信号时,它使用System.exit(1)存在jvm。

似乎IDEA从调试中恢复了JVM,然后发送STOP信号。因此,直到收到STOP信号,该过程才继续。

我在https://youtrack.jetbrains.com/issue/IDEA-155007打开了一个错误

关于debugging - 为什么intellij想法不能立即终止调试过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36745457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com