When Shutdown Hooks Break Bad

前端 未结 5 582
暖寄归人
暖寄归人 2021-01-17 16:53

If I add a shutdown hook to my Java program\'s runtime like so:

public class MyShutdownHook implements Runnable
{
    @Override
    public void run(         


        
5条回答
  •  无人及你
    2021-01-17 17:41

    They only run if the process "shuts down normally." If the process is killed forcefully from the OS or if it's crashing due to resource issues (e.g., out of memory), shutdown hooks won't be invoked.

提交回复
热议问题