Home » JAVA Programming » Multithreading » Question
  1. 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();
    }
    }
    1. False
    2. True
    3. False
      False
    4. True
      True
    5. 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.



Your comments will be displayed only after manual approval.