1、JVM关闭
(1)正常关闭
所有非守护线程执行结束
System.exit(0)
ctrl+c
kill -15 SIGTERM信号
(2)异常关闭
RuntimeExcetion
OOM
(3)强制关闭
kill -9 SIGKILL 信号
Runtime.halt()
断电
系统关机
系统crash
2、实例
public void start(){
Runtime.getRuntime().addShutdownHook(new Thread(){
public void run(){
try{
LogService.this.stop();
}catch(InterruptedException){
}
}
});
}











