61.
What will be the output of the following Java code?
class newthread implements Runnable
{
Thread t;
newthread()
    {
  t1 = new Thread(this,"Thread_1");
  t2 = new Thread(this,"Thread_2");
  t1.start();
  t2.start();
}
public void run()
    {
  t2.setPriority(Thread.MAX_PRIORITY);	
  System.out.print(t1.equals(t2));
    }    
}
class multithreaded_programing
{
    public static void main(String args[])
    {
        new newthread();        
    }
}

63.
Which of these keywords are used to implement synchronization?
class newthread extends Thread
{
Thread t;
String name;
newthread(String threadname)
    {
  name = threadname;
  t = new Thread(this,name);
  t.start();
}
public void run()
    {
    }

}
class multithreaded_programing
{
    public static void main(String args[])
    {
  newthread obj1 = 	 new newthread("one");
  newthread obj2 =	 new newthread("two");
        try
        {
            obj1.t.wait();	
            System.out.print(obj1.t.isAlive());
        }
        catch(Exception e)
        {
  System.out.print("Main thread interrupted");
        }
    }
}

65.
Which of the following stops execution of a thread?

66.
What will be the output of the following Java program?
class newthread extends Thread
{
Thread t;
String name;
newthread(String threadname)
    {
  name = threadname;
  t = new Thread(this,name);
  t.start();
}
public void run()
    {
    }

}
class multithreaded_programing
{
    public static void main(String args[])
    {
  newthread obj1 = 	 new newthread("one");
  newthread obj2 =	 new newthread("two");
        try
        {
            Thread.sleep(1000);	
            System.out.print(obj1.t.isAlive());
        }
        catch(InterruptedException e)
        {
  System.out.print("Main thread interrupted");
        }
    }
}

68.
What is true about time slicing?

Read More Section(Threads)

Each Section contains maximum 100 MCQs question on Threads. To get more questions visit other sections.