Home » JAVA Programming » Multithreading » Question
  1. 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();
    }
    }
    1. false
      false
    2. true
      true
    3. true
    4. false
    5. None of these
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.



Your comments will be displayed only after manual approval.