-
What is the output of this program?
class newthread implements Runnable
{
Thread thread;
newthread()
{
thread = new Thread(this,"New Thread created...");
thread.start();
}
public void run()
{
thread.setPriority(Thread.MAX_PRIORITY);
System.out.println(thread);
}
}
public class multithreaded_Example
{
public static void main(String args[])
{
new newthread();
}
}
-
- Thread[New Thread created...,10,main]
- [New Thread created...,10,main]
- New Thread created...
- [New Thread created...,10,main]Thread
- None of these
Correct Option: A
Thread thread has been made with default priority value 5 but in run method the priority has been explicitly changed to MAX_PRIORITY of class thread, that is 10 by code ‘thread.setPriority(Thread.MAX_PRIORITY);’ using the setPriority function of thread t.