When Shutdown Hooks Break Bad

前端 未结 5 611
暖寄归人
暖寄归人 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:31

    If you pull the plug out the back of your computer then the shut-down hook won't run. Other situations include:

    • The process being killed on a POSIX OS with SIGKILL (-9).
    • Similarly if you elect to terminate an "unresponsive" process under Windows the shut-down hook may not complete.

提交回复
热议问题