java
用途
1應用程序正常退出
2虛擬機非正常退出
實例
public class TestOnExit {
public TestOnExit(){
doShutDownWork();
}
private void doShutDownWork(){
Runtime
public void run(){
System
}
});
}
public static void main(String[] args) {
TestOnExit exit=new TestOnExit();
long beginTime=System
for(int i=
try {
System
Thread
} catch (InterruptedException e) {
e
}
}
long endTime=System
System
}
}
可以做個測試
執行ctrl+c
然後再試試kill
但是遇到kill
kill
我又試了下kill
然後看運行的結果
是執行了鉤子函數的
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27169.html