How to get and set the thread name?

class demo implements Runnable
{
public void run(){
System.out.println("hi\t"+Thread.currentThread().getName());}
public static void main(String[] args){
demo d=new demo();
Thread t1=new Thread(d,"My Thread");
//t1.setName("My Thread");
System.out.println(t1.getName());
t1.start();
}};

No comments:

Post a Comment