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

The getName() function is used to obtain the name of the thread, in this code the name given to thread is ‘Thread One’.



Your comments will be displayed only after manual approval.