看板 java 關於我們 聯絡資訊
※ 引述《superlubu (叔叔你人真好)》之銘言: : public class c extends b { : public c() { System.out.println("instance of class c, created."); } : protected void finalize() throws Throwable { : System.out.println("instance of class c, finalized."); : } : public static void main(String arg[]) throws Exception { : c obj = new c(); : obj = null; : System.gc(); : Thread.sleep(6000000); : } : } : 結果如下: : instance of class a, created. : instance of class b, created. : instance of class c, created. : instance of class c, finalized. 呵, 要呼叫 super.finalize() 才行啊 http://farm3.static.flickr.com/2007/2334136379_5d6b7a484d_o.png
(tij, p333) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.133.80.216
tkcn:嗯...所以比較合理的作法似乎是吧 super.finalize() 放最後? 03/15 19:44