Java Thread States Explained: 6 States with Visual Diagrams
This article provides a comprehensive explanation of Java's six thread states—New, Runnable, Blocked, Waiting, Timed Waiting, and Terminated—with visual diagrams illustrating each state's transitions and typical triggers such as lock acquisition, wait/notify, and timeout mechanisms.
1. New (New)
A thread has been created but has not yet started execution. The diagram illustrates the initial state before the start() method is invoked.
2. Runnable (Runnable)
The Runnable state encompasses two sub-states: Ready (waiting for CPU time) and Running (actually executing). The diagram shows the thread in the runnable pool, eligible for scheduling.
3. Blocked (Blocked)
The thread is blocked and paused, typically because it is waiting to acquire a monitor lock (e.g., entering a synchronized block/method already held by another thread). Once the lock becomes available, the thread transitions back to the Ready state.
4. Waiting (Waiting)
The thread is blocked indefinitely, waiting for another thread to perform a specific action. Common causes include calling Object.wait() without a timeout, Thread.join() without a timeout, or LockSupport.park(). The thread resumes only when another thread calls notify()/notifyAll() on the same object, or the joined thread terminates, or LockSupport.unpark() is called.
5. Timed Waiting (Timed Waiting)
The thread is blocked for a specified maximum time, waiting for another thread to perform an action. Examples include Thread.sleep(long), Object.wait(long), Thread.join(long), LockSupport.parkNanos/parkUntil, and CompletableFuture.get with timeout. If the timeout expires before the awaited event occurs, the thread automatically returns to the Ready state.
6. Terminated (Terminated)
The thread has completed its execution (run() method finished normally or threw an uncaught exception) and is no longer alive. It cannot be restarted.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architect Chen
Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
