Java学习笔记(对象的释放)(2)

public class GarbageC {
 public static void main(String[] args) {
 
  while(!Chair.f) {
    new Chair();
    new String("To take up space");
  }
  System.out.println(
  "After all Chairs have been created:\n" +
  "total created = " + Chair.created +
  ", total finalized = " + Chair.finalized);
  String theMethString ="after";
  if(theMethString.equals("before")) {
   System.out.println("gc():");
   System.gc();
   System.out.println("runFinalization():");
   System.runFinalization();
  }
  System.out.println("bye!");
  if(theMethString.equals("after"))
    System.runFinalizersOnExit(true);
  }
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/bf30dc8145fd58eb55212da7c56baca2.html