虚拟机钩子,在程序结束的时候会运行该线程 Runtime.getRuntime().addShutdownHook(new Thread(){ public void run(){ System.out.println("application will exit ...."); } });