-
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());
}
}
-
- main
- Thread one
- Thread
- Name
- 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’.