简体   繁体   English

Netbeans-Java应用程序可以响应“停止”吗?

[英]Netbeans - Can a Java Application React to 'Stop'?

I've googled for quite some time now but I couldn't find any threads about if an application, started with Netbeans as 'Run' or 'Debug', is able to recognize if you 'Stop' it with Netbeans (clicking on the big red square at 'Outputs' or in the 'Debug' toolbar) and still is able to do some work, ie write a config before terminating. 我已经在Google上搜索了很长时间,但是我找不到任何有关以Netbeans作为“运行”或“调试”启动的应用程序是否能够识别您是否通过Netbeans“停止”该应用程序的线程。 “输出”或“调试”工具栏中的红色大方块),仍然能够执行某些工作,即在终止之前编写配置。

I guess it can't because it probably just kills the JRE thread, but maybe I'm wrong and there is a chance to let the application do some work even if it gets shut down like this. 我猜不能,因为它可能只是杀死了JRE线程,但是也许我错了,即使这样关闭了应用程序,也有机会让应用程序执行一些工作。

The stop kills the JVM. 停止会杀死JVM。 The JVM has no way to detect if it is killed thus there is no way to do something after that. JVM无法检测到它是否被杀死,因此之后无法执行任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM