-
What is the output of this program?
class N extends Thread
{
Thread thread;
String Str;
N(String ThreadName)
{
Str = ThreadName;
thread = new Thread(this,Str);
thread.start();
}
public void run()
{
}
}
public class multithreading_EqualsExample
{
public static void main(String args[])
{
N object1 = new N("Hello");
N object2 = new N("Java");
try
{
System.out.print(object1.thread.equals(object2.thread));
}
catch(Exception e)
{
System.out.print("Running main thread...");
}
}
}
-
- Main Thread Running...
- First
- Second
- True
- False
Correct Option: E
Thread.sleep(1000) has caused all the threads to be suspended for some time, hence onject1.thread.isAlive() returns false.