Code :
package Atharva;
public class Test extends Thread
{
@Override
public void run()
{
System.out.println("run: "+Thread.currentThread().getName());
}
void m1()
{
System.out.println(" m1 method: "+Thread.currentThread());
}
static void m2()
{
System.out.println(" m2 method: "+Thread.currentThread());
}
public static void main(String args[])
{
Test th = new Test();
System.out.println(" main method: "+Thread.currentThread());
m2();
new Test().m1();
//new Test().run();
th.setName("CodingAtharva");
th.start();
}
}
public class Test extends Thread
{
@Override
public void run()
{
System.out.println("run: "+Thread.currentThread().getName());
}
void m1()
{
System.out.println(" m1 method: "+Thread.currentThread());
}
static void m2()
{
System.out.println(" m2 method: "+Thread.currentThread());
}
public static void main(String args[])
{
Test th = new Test();
System.out.println(" main method: "+Thread.currentThread());
m2();
new Test().m1();
//new Test().run();
th.setName("CodingAtharva");
th.start();
}
}