Set Thread Name - Java Thread

Java examples for Thread:Thread Operation

Description

Set Thread Name

Demo Code

 
public class Main {
        public static void main(String[] args) {
               //from www . ja  v  a2  s . com
                //get currently running thread object
                Thread currentThread = Thread.currentThread();
                System.out.println(currentThread);
               
                currentThread.setName("Set Thread Name Example");
               
                System.out.println("Thread Name : "+ currentThread.getName());
        }
}

Result


Related Tutorials