public class setname implements Runnable {
@Override
public void run() {
System.out.println(Thread.currentThread());
}
public static void main(String[] args) {
Thread t1 = new Thread(new setname(), "Thread a");
t1.start();
Thread t2 = new Thread(new setname());
t2.setName("Thread b");
t2.start();
System.out.println(t1.getName());
}
}
Output
Thread[Thread a,5,main] Thread a Thread[Thread b,5,main]If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.