Wednesday, 7 September 2011

Single Thread

import java.io.*;
public class single
{
public static void main(String st[]) throws IOException
{
Thread th=new Thread();
System.out.println("Numbers are printed line by line after 5 sec");
 try
{
for(int i=1;i<=10;i++)
{
 System.out.println(i);
 th.sleep(5000);
}
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
e.printStackTrace();
}
}
}

No comments:

Post a Comment