Posted on 2010-10-14 09:54
zdxue 阅读(170)
评论(0) 编辑 收藏
1 public class App {
2
3 public static void main(String[] args) {
4 System.out.println(1);
5 Runtime.getRuntime().addShutdownHook(new Thread(new AppExitHook()));
6 System.out.println(2);
7 System.exit(0);//
8 //Runtime.getRuntime().halt(0); //强行终止
9 System.out.println(3);
10 }
11 }
12
1 public class AppExitHook implements Runnable {
2
3 public void run() {
4 System.out.println("App exit hook running");
5 }
6
7 }
8