// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package e_threads;
public class T3 {
   private final static int N = 10;
   public static void main(String[] args) throws Exception {
      MultiThread[] t = new MultiThread[N];
      for(int i = 0; i < N; i++) {
         t[i] = new MultiThread(new Info(i));
      }
      for(int i = 0; i < N; i++) {
         t[i].start();
      }
      for(int i = 0; i < N; i++) {
         t[i].join();
      }
   }
}

class MultiThread extends Thread {
   private Info inf;
   public MultiThread(Info inf) {
      this.inf = inf;
   }
   public void run() {
      System.out.println(inf.getV());
   }
}

class Info {
   private int v;
   public Info() {
      v = 0;
   }
   public Info(int v) {
      this.v = v;
   }
   public int getV() {
      return v;
   }
   public void setV(int v) {
      this.v = v;
   }
}
