class ThreadTest
{
static
{
Thread t=Thread.currentThread();
System.out.println("Name of current thread "+t.getName());
System.out.println("Priority of thread is "+t.getPriority());
try
{
t.sleep(5000);
t.setName("Vikrant");
t.setPriority(420);
}
catch(Exception e)
{
System.out.println(e);
}
}
public static void main(String arg[])
{
System.out.println("main() is started");
Thread t=Thread.currentThread();
System.out.println("Name of current thread "+t.getName());
System.out.println("Priority of thread is "+t.getPriority());
}
}

Like this:
Like Loading...
Related
JAVA, Java Program, Java Tutorial, Program, Thread, Thread Name Change, Tutorials