-
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_Example
{
public static void main(String args[])
{
N object1 = new N("First");
N object2 = new N("Second");
try
{
object1.thread.wait();
System.out.print(object1.thread.isAlive());
}
catch(Exception e)
{
System.out.print("Running Main Thread...");
}
}
}
-
- First
- Second
- Running Main Thread...
- All of above
- None of these
Correct Option: C
object1.thread.wait() causes main thread to go out of processing in sleep state hence causes exception and “Main thread interrupted” is printed.