Code :
public class Test extends Thread
{
@Override
public void run()
{
for(int i =1;i<=10;i++)
System.out.println("run: "+Thread.currentThread().getName());
try
{
Thread.sleep(1000);
}
catch(Exception e)
{
System.out.println( e.toString() );
}
}
public static void main(String args[]) throws InterruptedException
{
Test t = new Test();
t.setName(" CodingAtharva ");
t.start();
t.join();
for(int i =1;i<=10;i++)
System.out.println("main: "+Thread.currentThread().getName());
}
}
{
@Override
public void run()
{
for(int i =1;i<=10;i++)
System.out.println("run: "+Thread.currentThread().getName());
try
{
Thread.sleep(1000);
}
catch(Exception e)
{
System.out.println( e.toString() );
}
}
public static void main(String args[]) throws InterruptedException
{
Test t = new Test();
t.setName(" CodingAtharva ");
t.start();
t.join();
for(int i =1;i<=10;i++)
System.out.println("main: "+Thread.currentThread().getName());
}
}