Home » JAVA Programming » Multithreading » Question
  1. What is the name of the thread in output of this program?
    public class multithreaded_Name
    {
    public static void main(String args[])
    {
    Thread thread = Thread.currentThread();
    thread.setName("First");
    System.out.println(thread);
    }
    }
    1. First
    2. main
    3. Thread
    4. All of above
    5. None of these
Correct Option: A

The output of program is Thread[First,5,main], Since we have not explicitly named the thread they are named by the group to they belong i:e main method. Hence they are named ‘main’.



Your comments will be displayed only after manual approval.