Multithreading

This Test will cover the basic introduction threads, its properties and the complete Multithreading feature of Java.

Q. In Java, each thread has its own ________, in which it runs ?
Q. In Java, by default every thread is given a _________ .
Q. What will happen if we call run() directly, without start() ?
Q. Which two are valid constructors for Thread class ?
  1. Thread(Runnable r, String name)
  2. Thread()
  3. Thread(int priority)
  4. Thread(Runnable r, ThreadGroup g)
Q. What Exception is thrown when you start a thread twice ?
Q. Which class or interface defines the wait(), notify(), and notifyAll() methods ?
Q. Which method will contain the body of the thread ?
Q. What is the Output of given code ?
class MyThread extends Thread 
{
 public static void main(String[] args)
 {
  MyThread my = new MyThread();
  Thread t = new Thread(my);
  t.start();
 }
public void run()
{
 for(int i=0; i< 3; i++){
 System.out.println(i+"..")
} } }
Q. Which of the following statement is not correct ?
Q. What will be the Output of given code ?
public class Test implements Runnable
{
  public void run()
  {
    System.out.println("r1 ");
    System.out.println("r2 ");
  }
    
 public static void main( String[] args )
 {
    Thread t = new Thread(new Test()); 
    t.start();
    System.out.println("m1 ");
    t.join();
    System.out.println("m2 ");
 }
}
Q. Give One Word for ?
A situation where two or more threads are blocked forever and waiting for each other to release resources.

SUBMIT TEST