/* Displaying the list of threads with ThreadLister within each printing thread */

public class Test9 {
  public static void main(String args[]){
    StarterThread starter = new StarterThread();
    starter.start();
  }
}


class StarterThread extends Thread{

  static final int NUM_THREADS = 10;
  static MyThread9 myThreads[];

  public void run(){
    currentThread().setPriority(MAX_PRIORITY);
    myThreads = new MyThread9[NUM_THREADS];
    for (int i=0; i < NUM_THREADS; i++)
      myThreads[i] = createThread(i);
    for (int i=0; i < NUM_THREADS; i++)
      myThreads[i].start();
    try {
      for (int i=0; i < NUM_THREADS; i++)
	myThreads[i].join();
    } catch (InterruptedException e){
      return;
    }
    System.out.println();
  }

  public static MyThread9 createThread(int i){
    return new MyThread9(new Integer(i).toString(), i+1);
  }
}

class MyThread9 extends Thread{

  static final int NUM_PRINTS = 30;

  MyThread9(String s){
    super(s);
  }

  MyThread9(String s, int priority){
    super(s);
    setPriority(priority);
  }

  public void run(){
    ThreadLister.main(null);
    for (int i=0; i < NUM_PRINTS; i++){
      System.out.print(getName());
    }
  }
}



