package com.java.gc;
公共类FinalizeDemo { static FinalizeDemo s;
public static void main(String[] args) throws InterruptedException
{
FinalizeDemo f = new FinalizeDemo();
System.out.println("f hashcode:" +f.hashCode());
f=null;
System.gc();
Thread.sleep(5000);
System.out.println("s hashcode:"+s.hashCode());
s=null;
Thread.sleep(10000);
System.out.println("ENd of main");
}
public void finlaize()
{
System.out.println("Finlaize method called");
s=this;
}
}
在运行此代码时获取NPE,有人可以帮助我吗?