package basicsleep;
import java.util.logging.Level;
import java.util.logging.Logger;
public class BasicSleep
{
public static void main(String[] args)
{
Thread t = new Thread();
for(int i=0;i<5;i++)
{
try
{
t.sleep(1000); ///this will stop the program for 1 second
}
catch (InterruptedException ex)
{
System.out.println("There is a Problem");
}
System.out.println("I : "+i);
}
}
}
Output
I : 0
I : 1
I : 2
I : 3
I : 4
Add your comment