public class MainThread
{
public static void main(String arg[])
{
Thread t=Thread.currentThread();
System.out.println("Current Thread:"+t);
//Change Name t.setName("My Thread ");
System.out.println ("After the name is Changed:"+t);
try {
for(int i=2;i>0;i--)
{
System.out.println(i);
Thread.sleep(1000);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
**OUTPUT***
D:\TY\Adv Java>javac MainThread.java
D:\TY\Adv Java>java MainThread
Current Thread:Thread[main,5,main]
After the name is Changed:Thread[My Thread ,5,main]
2 1