-
What is the output of this program?
class N extends Thread
{
Thread thread, thread1, thread2;
N()
{
thread1 = new Thread(this,"Thread_1");
thread2 = new Thread(this,"Thread_2");
thread1.start();
thread2.start();
}
public void run()
{
thread2.setPriority(Thread.MAX_PRIORITY);
System.out.println(thread1.equals(thread2));
}
}
public class multithreading_Example
{
public static void main(String args[])
{
new N();
}
}
-
- False
- True
- False
False - True
True - None of these
Correct Option: C
This program is 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.