Thread States Overview: The Five-State Model
You'll learn: how Java threads move through five distinct states from creation to termination, forming the lifecycle of every thread you start.
The Five-State Model Explained
Every thread in Java exists in exactly one of five states at any given moment:
-
NEW – The thread has been created but not yet started. You've called the constructor, but not
start(). -
RUNNABLE – The thread is eligible to run. It may be actively executing on a CPU, or waiting for CPU time from the operating system's scheduler.
-
BLOCKED – The thread is waiting to acquire a lock (monitor) held by another thread. It cannot proceed until that lock becomes available.
-
WAITING – The thread is indefinitely waiting for another thread to perform a specific action (like notifying it). It won't resume until explicitly woken.
-
TERMINATED – The thread has completed execution. Its
run()method has finished, either normally or by throwing an exception.
The Lifecycle Flow
Think of a thread like a worker in a factory:
- NEW: Hired but hasn't clocked in yet
- RUNNABLE: On the floor, working or waiting for a task assignment
- BLOCKED: Stuck at a locked door, waiting for someone to open it
- WAITING: On break, waiting for a supervisor's call
- TERMINATED: Shift ended, gone home
Transitions happen automatically: calling start() moves NEW → RUNNABLE. Finishing the run() method moves RUNNABLE → TERMINATED. Encountering synchronization issues moves RUNNABLE → BLOCKED.
Java's Thread.State enum represents these states, and you can check a thread's current state with the getState() method.
Key Takeaway: Every Java thread progresses through a five-state lifecycle—NEW, RUNNABLE, BLOCKED, WAITING, and TERMINATED—with transitions driven by starting, scheduling, synchronization, and completion events.