class Thread16 extends Thread
{
public void run()
{
for(int i=1;i<=5;i++)
{
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println(e);
}
System.out.println(" "+i);
}
}
public static void main(String surat[])
{
Thread16 t1=new Thread16();
Thread16 t2=new Thread16();
t1.run();
t2.run();
}
}
Output:
{
public void run()
{
for(int i=1;i<=5;i++)
{
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println(e);
}
System.out.println(" "+i);
}
}
public static void main(String surat[])
{
Thread16 t1=new Thread16();
Thread16 t2=new Thread16();
t1.run();
t2.run();
}
}
Output:
No comments:
Post a Comment