This is an unchecked exception and as the name indicates, is thrown by the Java runtime environment, when the programmer is trying to modify the state of the thread when it is illegal. It is also of commonsense, there is no meaning of starting a thread which is already started. If the programmer tries to do so, the JVM throws IllegalThreadStateException.
Following is the hierarchy.
Object –> Throwable –> Exception –> RuntimeException –> IllegalThreadStateException
Complete hierarchy of exceptions is available at "Hierarchy of Exceptions – Checked/Unchecked Exceptions".
Following program illustrates.
public class Demo extends Thread
public static void main(String args)
Demo d1 = new Demo();
The start() method of Thread class makes d1 thread starting and when started it will be executing the task assigned. While the task is going on, again activating the same thread with start() method is of no meaning. At this juncture, the JVM throws IllegalThreadStateException. Observe the screenshot.
Pass comments and suggestions to improve the quality of this tutorial "IllegalThreadStateException".