Consider the following program and predict the output:
class MyThread extends Thread { public void run() { try { this.join(); } catch (InterruptedException e) { e.printStackTrace(); }//from w w w.ja v a2 s. c o m System.out.println("In run method; thread name is: " + Thread. currentThread().getName()); } public static void main(String args[]) { Thread myThread = new MyThread(); myThread.start(); } }
d)
Calling this.join()
will result in indefinite waiting since the thread is waiting for the thread itself to terminate.