package FinalizeTest;public class Person { public Person(){ System.out.println("person created"); } @Override protected void finalize() throws Throwable { // TODO Auto-generated method stub System.out.println("gc "); throw new Exception("no effect"); }}package FinalizeTest;public class MainTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Person per = new Person(); per = null; System.gc(); System.out.println("hello world"); }}输出为person createdhello worldgc 代码如上所示, 求解释为什么hello world会在gc之前输出??
添加回答
举报
0/150
提交
取消