Thursday, March 5, 2015

Pause Thread Using Sleep Method in java pgm



Pause Thread Using Sleep Method

public class PauseThreadUsingSleep
{
public static void main(String[] args)
{
System.out.println("Print number after pausing for 1000 milliseconds");
try
{
 for(int i=0; i< 5; i++)
{
 System.out.println(i);
 Thread.sleep(1000);
   }
}
catch(InterruptedException ie)
{
System.out.println("Thread interrupted !" + ie);
                           }
    }
}

No comments:

Post a Comment