/***
 * A tiny application to demonstrate Threads.  Remember to call "Start()" on 
 * threads instead of "run()" for your first thread programs.
 *
 *
**/
public class ThreadExample {

public static void main(String argv[])
  {
    System.err.println("ThreadExample.main() ");

    myThread t1 = new myThread(10,1000,"celica");
    myThread t2 = new myThread(10,2000,"  chevy");
    myThread t3 = new myThread(5,5000,"     vega");
    t3.start();
    t2.start();
    t1.start();
  }
} // class ThreadExample


/***
 * A really small test thread class
 * 
**/
  class myThread extends Thread {
    int max, mySleep;
    String myName;
/***
 * 
 * @param n number of iterations
 * @param millisecs to sleep
 * @param name name of the thread
**/
    public myThread(int n,int sleep, String name)
    {
      max = n;
      mySleep = sleep;
      myName = name;
    }

    public void run()
    {
      for(int i=0;i<max;i++)
	{
	  System.out.println("" + this);
	  try {	  sleep(mySleep);}
	  catch(Exception ex){ System.out.println("" + ex);}

	}
    }

    public String toString()
    {
      return(myName + ", iterations = " + max + ", sleep = " + mySleep );
    }


  } // class myThread


