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.

解决方案 »

  1.   

    我觉得是阿
    好几次把书上的例子哪来,(jdk1.1通过)再jdk1.4下运行就提示,,,警告
      

  2.   

    thinkinjava讲的只是一种方法和思想,很多东西不一定就要按上面的去做啊
      

  3.   

    "technically the order of finalization of objects is unspecified" 你看书上的这句话了吗?
      

  4.   

    为什么结果不一样?
    答 是因为不同的版本的问题。
    我在 java 1.2 下运行,结果与书上一致。
    java 1.3.0 下运行,结果与你的一致。原来的顺序容易理解,现在这个方法被deprected了。
    所以,你不知道什么时候调用哪个object 的finalize();
    因为,这要看VM如何安排object 的调用堆栈的。