The Life Cycle of a Thread

A thread can undergo one of any five states during the complete life cycle (see Figure 11.4). The five states are

Figure 11.4. The life cycle of a thread can illustrate all five states.

  • New

  • Runnable

  • Running

  • Not Runnable

  • Dead

When the SimpleThread class was instantiated in the previous section, the thread was in the New state. No system resources are allocated to a thread in the New state. The only method that can be called on a new thread is the start method; otherwise an IllegalThreadStateException will be thrown.

When the start method is called on a new thread, the thread enters the Runnable state and is considered to ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.