I know that "Once a thread has been started, it can never be started again".
But I want to know why?
What's the wrong if it is allowed to start again later in another time?
Why, the only time you can start a thread is when it is in the NEW state? Why it can't be also after DEAD at least?
public class ThreadDemo {
public static void main(String[] args) {
Thread thread = new Thread(new MyRunnable());
thread.start();
thread.start(); // java.lang.IllegalThreadStateException
}
}
class MyRunnable implements Runnable{
@Override
public void run() {
System.out.println("run().Thread.currentThread().getName() : " + Thread.currentThread().getName());
}
}
Note : I have gone through these posts. But my question is much more specific and descriptive.
Here, please note that I want to know this mainly to understand the threads internal functionalities and how the related aspects like GC works with thread states.