Could somebody pl explain me why this code is not throwing runtime exception when i am trying to invoke start() on dead thread and also when getName() method is called on dead thread it is not responding as we can call methods on the dead thread instance except start().
(1) To see the name of the dead thread after the main thread wakes up, change t.getName() to System.out.println(t.getName());
(2) If you add another t.start() just after the first one, you will get an IllegalThreadStateException. If you wait until the thread returned from the run() method, you will not get the exception. This is a bug.
The same question was asked on the
Java Developer Connection forums:
http://forum.java.sun.com/thread.jsp?forum=52&thread=94758 Here is the bug report:
http://developer.java.sun.com/developer/bugParade/bugs/4180576.html If you don�t have a logon to the bug database, here are the highlights:
Synopsis:Thread.start() doesn't throw IllegalThreadStateException
State: In progress, bug
Submit Date: Oct 12, 1998