Master Java Thread Lifecycle: From NEW to TERMINATED Explained

Understanding Java's thread lifecycle—from creation (NEW) through runnable execution, waiting states, blocking, and termination—is essential for multithreaded development, and this guide breaks down each state, transitions, and relevant code examples to help you master concurrency concepts.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Master Java Thread Lifecycle: From NEW to TERMINATED Explained

Java thread lifecycle is crucial for multithreaded development and a common interview question.

Thread Lifecycle Overview

Diagram shows all states.

States: NEW, RUNNABLE, WAITING, TIMED_WAITING, BLOCKED, TERMINATED.

NEW – initial state, thread created but not started.

RUNNABLE – thread ready to run or executing.

WAITING – waiting indefinitely for another thread.

TIMED_WAITING – waiting with a timeout.

BLOCKED – waiting to acquire a lock.

TERMINATED – thread has finished execution.

These states can be grouped into normal flow and abnormal situations.

Normal flow: NEW → RUNNABLE → TERMINATED.

Abnormal situations: thread may enter WAITING, TIMED_WAITING, or BLOCKED before returning to RUNNABLE.

NEW

A thread is in NEW state after creation and before start() is called.

Example:

Thread t = new MyThread();

RUNNABLE

After calling start(), the thread moves from NEW to RUNNABLE.

In RUNNABLE, the thread may be executing or waiting for CPU time allocated by the JVM scheduler.

Example:

Thread t = new MyThread();
t.start();

WAITING

A thread enters WAITING when it calls methods such as Object.wait(), Thread.join(), or LockSupport.park() without a timeout.

Example: threadA calls threadB.join() and waits until threadB finishes.

TIMED_WAITING

Similar to WAITING but with a time limit, entered via methods like Thread.sleep(), Object.wait(long), Thread.join(long), LockSupport.parkNanos(), or LockSupport.parkUntil().

BLOCKED

A thread is BLOCKED when it attempts to enter a synchronized block or method that is already held by another thread.

Example: threadA holds synchronized method A(), threadB trying to call A() becomes BLOCKED.

TERMINATED

The thread has completed execution, either normally or due to an exception.

Summary

The lifecycle diagram shows the normal path NEW → RUNNABLE → TERMINATED and the possible abnormal paths involving WAITING, TIMED_WAITING, and BLOCKED, after which the thread returns to RUNNABLE before termination.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendJavaconcurrencyThreadLifecyclemultithreading
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.