天天看點

監聽JVM關閉

使用runtime的addshutdownhook(thread)方法:

輸出結果:

監聽JVM關閉

也可使用runtime.removeshutdownhook(thread)移除監聽線程。