A Java thread goes through multiple states from creation to termination.
These states are defined in the Thread.State enum.

Lifecycle Diagram (Simplified)

NEW → RUNNABLE → RUNNING → (WAITING / BLOCKED / TIMED_WAITING) → TERMINATED

Thread States

StateDescription
NEWThread is created but not started
RUNNABLEThread is ready to run, waiting for CPU
RUNNINGThread is currently executing its run() method
BLOCKEDWaiting for a lock held by another thread
WAITINGWaiting indefinitely (e.g. wait())
TIMED_WAITINGWaiting with a timeout (e.g. sleep(), join(timeout))
TERMINATEDThread has completed execution or was stopped

Example

Thread t = new Thread(() -> {
    try {
        Thread.sleep(1000); // TIMED_WAITING
    } catch (InterruptedException e) {}
});
 
System.out.println(t.getState()); // NEW
t.start();
System.out.println(t.getState()); // RUNNABLE → RUNNING

Transition Triggers

ActionState Change
start()NEW → RUNNABLE
Thread gets CPURUNNABLE → RUNNING
sleep(), join(), etcRUNNING → TIMED_WAITING
wait()RUNNING → WAITING
Lock contentionRUNNING → BLOCKED
Thread endsAny → TERMINATED

Tip

Be ready to:

  • explain thread states with real examples,
  • describe how sleep(), wait(), join() affect state,
  • use getState() for debugging multithreaded apps.

Parent: _Multithreading