public class ThreadTester

{
   public static void main( String args[] )
   {

      PrintThread thread1 = new PrintThread( "thread1" );
      PrintThread thread2 = new PrintThread( "thread2" );
      PrintThread thread3 = new PrintThread( "thread3" );
      PrintThread thread4 = new PrintThread( "thread4" );

      System.err.println( "\nStarting threads" );

      thread1.start();
      thread2.start();
      thread3.start();
      thread4.start();

      System.err.println( "Threads started\n" );
   }
}

class PrintThread extends Thread
{
   private int sleepTime = (int) ( Math.random() * 5000 );

   public PrintThread( String threadName )
   {
      super( threadName );   

      System.err.println( "Name: " + getName() + ";  sleep: " + sleepTime );
   }

   public void run()
   {
      try
      {
         System.err.println( getName() + " going to sleep" );
         Thread.sleep( sleepTime );
      }
      catch ( InterruptedException ignore ) {}

      System.err.println( getName() + " done sleeping" );
   }
}