-
What is the output of this program?
class N extends Thread
{
Thread thread1,thread2;
N()
{
thread1 = new Thread(this,"Thread");
thread2 = new Thread(this,"Thread");
thread1.start();
thread2.start();
}
public void run()
{
thread2.setPriority(Thread.MAX_PRIORITY);
System.out.println(thread2.equals(thread1));
}
}
public class multithreaded_programing
{
public static void main(String args[])
{
new N();
}
}
-
- false
false - true
true - true
- false
- None of these
- false
Correct Option: A
This program was previously done by using Runnable interface, here we have used Thread class. This shows both the method are equivalent, we can use any of them to create a thread.