// this code demonstrates the usage of the sleep() method

public class ThreadDemo2
{
  public static void main(String[] args)
  {
    SleepThread sT = new SleepThread();  // create a thread and run it  
    sT.start();
  }
}

class SleepThread extends Thread
{
  public void run()
  {
    for (int i=0; i<100; i++)   
    {         
      try
      {
        System.out.print(i + " ");
        if (i==25) sleep(3000);          // sleep 3 sec
        if (i==75) sleep(5000);          // sleep 5 sec
      }
      catch(InterruptedException e) {}   // required by using sleep() method
    }
  }
}
  
