// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class TGC {
   public static void main(String[] args) throws Exception {
      for(int i = 1; i <= 10000; i++) {
         Thread t = new T();
         t.start();
         t.join();
         t = null;
         if((i % 100) == 0) {
            if((i % 1000) == 0) {
               System.out.print(T.n + " -> ");
               System.gc();
               System.out.println(T.n);
            } else {
               System.out.println(T.n);
            }
         }
      }
   }
}

class T extends Thread {
   static int n = 0;
   public T() {
      n++;
   }
   public void run() {
   }
   protected void finalize() {
      n--;
   }
}
