照你这样说,那么首先应该执行protected void finalize() 中的
 System.out.println(
        "Beginning to finalize after " +
        created + " Chairs have been created");
因为满足条件 if(!gcrun) 

解决方案 »

  1.   

    while(!Chair.f) {
          new Chair();
          new String("To take up space");
        }new Chair()执行了47次后,i==47 了,此时未执行 if(i==47)这个语句(否则会输出Finalizing Chair #47...)。一直到执行了很多次new Chair()后,才执行protected void finalize() 中的if(!gcrun),if(i == 47)(因为运行结果先输出Beginning to finalize after 3189 Chairs have been created,再输出Finalizing Chair #47, Setting flag to stop Chair creation),哪有这样的呀?
      

  2.   

    new String("To take up space");
    这句就是用来引诱垃圾收集器的呀。