

import java.util.Vector;

public class ThreadTest extends Thread {
  public ThreadTest (String name) {
    super ();
    this.name = name;
  }

  public void run () {
    for (int i = 0; i < 10; i++) {
      System.out.println ("Thread " + name + " iteration: #" + i);
    }
  }

  public static void main (String [] s) {
    Vector threads = new Vector (s.length / 2);
    for (int i=0; i < s.length; i+=2) {
      if ((i + 1) > s.length) {
        continue;
      }
      ThreadTest t = new ThreadTest (s [i]);
      try {
        t.setPriority (Integer.parseInt (s [i+1]));
      }
      catch (Exception e) {
        t.setPriority (1);
      }
      threads.addElement (t);
    }

    for (int i = 0; i < threads.size (); i++) {
      ((ThreadTest) threads.elementAt (i)).start ();
    }

  }

  private String name;

}
