All pastes #162300 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-06 11:29 UTC
rendered paste body
class Zombie {
  private int id;
  public static int num;

  public Zombie( int ident ){
    this.id=ident;
  }


  protected void finalize(){
    System.out.println("Zombie "+this.id+" is finalized.");
  }

  public static void main(String[] args) {
    //Parse String to int
    num=Integer.parseInt(args[0]);

    if( num <= 0 ) {
      System.err.println("usage: Zombie [integer] ");
      System.exit(-2);
    }

    //create zombies
    Object[] zombie = new Object[num];
    for(int i=1;i<=num;i++){
      zombie[i]= new Zombie(i);
    }


    //garbage collect 
    System.gc();
    for(int j=1;j<=num;j++){
      zombie[j].finalize();
    }
  }
}//Zombie