How to gracefully handle the SIGKILL signal in Java

前端 未结 5 2104
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 11:34

How do you handle clean up when the program receives a kill signal?

For instance, there is an application I connect to that wants any third party app (my app) to se

5条回答
  •  耶瑟儿~
    2020-11-22 12:05

    You can use Runtime.getRuntime().addShutdownHook(...), but you cannot be guaranteed that it will be called in any case.

提交回复
热议问题