public static void sd() throws Exception {
Object f = new Object() {
public void finalize() {
System.out.println("Running finalize()");
}
};
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("Running Shutdown Hook");
}
});
f = null;
System.gc();
System.out.println("Calling System.exit()");
System.exit(0);
}
System.gc() call finalize();
System.exit(0) or process finished call shutdownHook;
7764

被折叠的 条评论
为什么被折叠?



