class A extends Thread
{
public void start()
{
for(int i=1;i<=5;i++)
{
System.out.println("threadA : "+i);
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
}
}
}
}
class StartThread
{
public static void main(String args[])
{
A a =new A();
a.start();
for(int i=1;i<=5;i++)
{
System.out.println("Main thread : "+i);
try
{
Thread.sleep(500);
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
}
}
}
}
{
public void start()
{
for(int i=1;i<=5;i++)
{
System.out.println("threadA : "+i);
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
}
}
}
}
class StartThread
{
public static void main(String args[])
{
A a =new A();
a.start();
for(int i=1;i<=5;i++)
{
System.out.println("Main thread : "+i);
try
{
Thread.sleep(500);
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
}
}
}
}
0 comments:
Post a Comment