runFinalizersOnExit(boolean) - Static method in class java.lang.System
Deprecated. This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
Deprecated. This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
好几次把书上的例子哪来,(jdk1.1通过)再jdk1.4下运行就提示,,,警告
答 是因为不同的版本的问题。
我在 java 1.2 下运行,结果与书上一致。
java 1.3.0 下运行,结果与你的一致。原来的顺序容易理解,现在这个方法被deprected了。
所以,你不知道什么时候调用哪个object 的finalize();
因为,这要看VM如何安排object 的调用堆栈的。