Here is the Java code to set the thread name.
public class Demo {
public static void main(String[] args) {
//get currently running thread object
Thread currentThread = Thread.currentThread();
System.out.println(currentThread);
currentThread.setName("Green Thread :)");
System.out.print("Thread Name is set to: ");
System.out.println(currentThread.getName());
}
}Thank you, keep learning and sharing.
