Home » JAVA Programming » Multithreading » Question
  1. 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...");
    }
    }
    }
    1. Main Thread Running...
    2. First
    3. Second
    4. True
    5. False
Correct Option: E

Thread.sleep(1000) has caused all the threads to be suspended for some time, hence onject1.thread.isAlive() returns false.



Your comments will be displayed only after manual approval.