Java Thread Lifecycle: The 6 Thread States & Transitions Explained

At any point during execution, every Java thread resides in exactly one of the six states defined in the java.lang.Thread.State enum.

Java Thread Lifecycle and State Transitions

Figure 11: Java Thread Lifecycle: Transition triggers between NEW, RUNNABLE, BLOCKED, WAITING, and TERMINATED.

The 6 Thread States Explained

  • 1. NEW: The thread object has been instantiated (new Thread()), but start() has not yet been called.
  • 2. RUNNABLE: The thread is executing or ready to execute in the JVM, actively managed by the OS thread scheduler.
  • 3. BLOCKED: The thread is paused waiting to acquire a monitor lock to enter a synchronized block or method.
  • 4. WAITING: The thread is waiting indefinitely for another thread to perform a specific action (e.g. Object.wait() or Thread.join() without timeout).
  • 5. TIMED_WAITING: The thread is sleeping or waiting up to a specified maximum duration (e.g. Thread.sleep(1000), wait(5000)).
  • 6. TERMINATED: The thread has finished executing its run() method or was aborted by an uncaught exception.

Synchronizing Threads with Thread.join()

public class ThreadJoinDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread worker = new Thread(() -> {
            System.out.println("Worker: Downloading large database backup...");
            try { Thread.sleep(2000); } catch (Exception e) {}
            System.out.println("Worker: Download finished!");
        });

        worker.start();

        System.out.println("Main: Waiting for worker to finish...");
        worker.join(); // Main thread pauses until worker terminates!

        System.out.println("Main: Resuming. All data downloaded successfully.");
    }
}

Next Step

When multiple threads access shared mutable state, race conditions occur. Let us explore Thread Synchronization and Monitor Locks. Proceed to: Java Thread Synchronization →

Frequently Asked Questions (FAQ)

Q1. What are the 6 official states of a Java Thread?
Defined in the java.lang.Thread.State enum: 1. NEW, 2. RUNNABLE, 3. BLOCKED, 4. WAITING, 5. TIMED_WAITING, and 6. TERMINATED.
Q2. What is the difference between BLOCKED and WAITING states?
A thread is BLOCKED when it is suspended waiting to acquire a synchronized monitor lock held by another thread. A thread enters WAITING when it voluntarily releases its lock and calls Object.wait() or Thread.join(), waiting for a notification.
Q3. How does Thread.join() work in Java?
Calling thread.join() causes the currently executing thread to pause and wait until the target thread finishes executing and enters the TERMINATED state.

Explore Related Java Tutorials

Accelerate your Java mastery by studying these tightly connected core tutorials:

Multithreading Basics →

Creating threads with Thread/Runnable.

Thread Synchronization →

Monitor locks and BLOCKED state.

Deadlock & Wait/Notify →

Transitioning out of WAITING.

Virtual Threads →

Unmounting virtual threads.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!