Threads ·
‹ Previous Next ›
⏱ 5 min read Modified: 2026-11-22

Thread States in Java: The Thread Lifecycle

Thread states in Java are the values of the java.lang.Thread.State enum returned by the getState() method of Thread. There are exactly six of them: NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING and TERMINATED. A thread moves through these states from the moment the object is created until its run() method finishes — that path is the thread lifecycle in Java.

If you learned multithreading from older books, you probably expect two more states, Running and Dead. They don't exist: a thread that is executing on a CPU core right now reports RUNNABLE. And you'll see the very same RUNNABLE for a thread that has been waiting a full minute for keyboard input in System.in.read() (see RUNNABLE during blocking I/O).

The 6 Thread.State Values and How a Thread Gets There

A Java thread is always in exactly one of the six Thread.State values: created but not started (NEW), ready to run or running (RUNNABLE), waiting for a monitor (BLOCKED), waiting for an event with no time limit (WAITING) or with a timeout (TIMED_WAITING), and finished (TERMINATED).

State What it means How a thread gets there How it leaves
NEW A Thread object has been created but not started yet. It isn’t a thread of execution yet and, naturally, isn’t running new Thread(...) start() → RUNNABLE
RUNNABLE The thread is running or is ready to run and waiting for the scheduler to give it a CPU start(); acquired the monitor after BLOCKED; got its event or timeout after WAITING/TIMED_WAITING To BLOCKED, WAITING, TIMED_WAITING or TERMINATED
BLOCKED Waiting for a monitor held by another thread Tried to enter a synchronized block or method while the monitor is taken; returning from wait() while the monitor is still held The monitor is released and this thread gets it → RUNNABLE
WAITING Waiting for another thread to act, with no time limit Object.wait(), t.join(), LockSupport.park() (which ReentrantLock.lock() and BlockingQueue.take() are built on) notify()/notifyAll(), thread t finishing for join(), unpark(), interrupt()
TIMED_WAITING The same kind of waiting, but with a timeout Thread.sleep(n), wait(n), join(n), LockSupport.parkNanos()/parkUntil() The timeout expires, plus anything that ends WAITING
TERMINATED The thread has finished run() returned normally or threw an uncaught exception It doesn’t — this is the final state

Thread.yield() isn’t in the table because it doesn’t change the state: the thread stays RUNNABLE and only hints to the scheduler that it’s willing to give up the CPU (more in Thread.yield() in Java). The same goes for priority and the daemon flag: a daemon is a property of a thread, not a state, and getState() doesn’t show it.

Running and Dead from older books

SCJP prep books and plenty of older articles describe the lifecycle with five states: New, Runnable (ready, but the scheduler hasn’t picked it yet), Running (executing), Waiting/blocked/sleeping and Dead. That’s a teaching model, not the API. In Thread.State, Runnable and Running are merged into a single RUNNABLE value, the Waiting/blocked/sleeping group is split into BLOCKED, WAITING and TIMED_WAITING, and Dead is called TERMINATED. In an interview, answer with the six enum values.

Thread Lifecycle in Java: State Transition Diagram

The thread lifecycle starts in NEW, goes through RUNNABLE and ends in TERMINATED. Every other state is a temporary stop: from BLOCKED, WAITING and TIMED_WAITING a thread always returns to RUNNABLE rather than jumping straight into another kind of waiting or to termination.

Java thread state diagram: NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, TERMINATED NEW moves to RUNNABLE after start() is called. From RUNNABLE a thread moves to BLOCKED when it waits for a synchronized monitor and returns once it gets the monitor. A thread enters WAITING via wait(), join() or park and returns after notify(), notifyAll() or when the joined thread ends. A thread enters TIMED_WAITING via sleep(n), wait(n) or join(n) and returns when the timeout expires. When run() finishes, the thread moves from RUNNABLE to TERMINATED. NEW RUNNABLE TERMINATED BLOCKED WAITING TIMED_WAITING start() run() finished waits for synchronized monitor got the monitor wait() / join() / park back: notify() / notifyAll() / joined thread ends sleep(n) / wait(n) / join(n) back: timeout expired, notify() or join ends
Solid arrows lead into a state, dashed arrows lead back to RUNNABLE. The diagram is simplified: after notify(), a thread that called wait() first goes to BLOCKED until it reacquires the monitor. interrupt() ends any kind of waiting except BLOCKED.

The diagram also shows why you can observe NEW only once and never return to it: not a single arrow points into NEW. Nor does any arrow leave TERMINATED.

getState(): Example with Output

The getState() method of Thread returns the thread’s current state. In the example below one thread goes through NEW → RUNNABLE → TIMED_WAITING → TERMINATED, and the main thread prints its state at each step.

public class ThreadStateExample {
    public static void main(String[] args) throws InterruptedException {
        Thread sleeper = new Thread(() -> {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }, "sleeper");

        System.out.println("After new:      " + sleeper.getState());
        sleeper.start();
        System.out.println("After start():  " + sleeper.getState());
        Thread.sleep(100); // let the thread reach sleep(500)
        System.out.println("During sleep:   " + sleeper.getState());
        sleeper.join();    // wait for it to finish
        System.out.println("After join():   " + sleeper.getState());
    }
}
After new:      NEW
After start():  RUNNABLE
During sleep:   TIMED_WAITING
After join():   TERMINATED

The first, third and fourth lines are stable. The second one is almost always RUNNABLE, but not guaranteed: if the new thread reaches Thread.sleep(500) before main calls getState(), you’ll see TIMED_WAITING. That’s true of the method in general: getState() is a snapshot taken at the moment of the call, and a microsecond later the state may be different. The Javadoc says outright that the method is designed for monitoring, not for synchronization. Don’t build logic like “if the thread is WAITING, then…” on top of it.

Why a pause gives you TIMED_WAITING rather than WAITING, and why a sleeping thread keeps its monitor, is covered in Thread.sleep() in Java.

BLOCKED vs WAITING: What’s the Difference

BLOCKED means the thread wants to enter a synchronized block, but another thread holds the monitor; it’s waiting for a resource and will move on by itself as soon as the monitor is free. WAITING means the thread itself called wait(), join() or park() and is waiting for an event from another thread: notify(), termination, unpark().

This is one of the most common multithreading interview questions, and it’s usually asked with code. What does this program print?

public class BlockedWaitingExample {
    private static final Object lock = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread holder = new Thread(() -> {
            synchronized (lock) {
                pause(1000); // holds the lock monitor for 1 second
            }
        }, "holder");
        Thread blocked = new Thread(() -> {
            synchronized (lock) { // the monitor is held by holder
            }
        }, "blocked");
        Thread waiter = new Thread(() -> {
            try {
                holder.join(); // waits for holder to finish
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }, "waiter");

        holder.start();
        Thread.sleep(100); // holder has time to grab the monitor
        blocked.start();
        waiter.start();
        Thread.sleep(100);

        System.out.println("holder:  " + holder.getState());
        System.out.println("blocked: " + blocked.getState());
        System.out.println("waiter:  " + waiter.getState());
    }

    private static void pause(long millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
}
holder:  TIMED_WAITING
blocked: BLOCKED
waiter:  WAITING

Most people expect holder to be RUNNABLE: it “owns” the monitor and is “working”, after all. But owning a monitor isn’t a state. Inside synchronized the thread is sleeping in sleep(1000), so it’s TIMED_WAITING, and it doesn’t let go of the monitor while it sleeps — which is exactly why blocked is stuck in BLOCKED. The rule to remember: sleep() and join() keep every monitor the thread holds, while wait() releases the monitor it was called on.

In practice the difference looks like this. A thread leaves BLOCKED without anyone’s help once the monitor owner exits its synchronized block; interrupt() won’t pull it out. A thread leaves WAITING only after a specific action by another thread, and interrupt() works too — the waiting method throws InterruptedException. There’s also a transition between the two: a thread woken up by notify() has to reacquire the monitor, so while it competes for it, it’s BLOCKED. That’s the core of the wait()/notify() mechanism: the waiting thread gives up the monitor, and must win it back before it continues.

RUNNABLE During Blocking I/O

A platform thread waiting for data in blocking I/O (InputStream.read(), a socket read, System.in.read()) is in the RUNNABLE state, not BLOCKED or WAITING. The JVM doesn’t track what a thread does inside a system call, so as far as it knows, the thread is “running”.

import java.io.IOException;

public class IoStateExample {
    public static void main(String[] args) throws InterruptedException {
        Thread reader = new Thread(() -> {
            try {
                System.in.read(); // waits for keyboard input
            } catch (IOException e) {
                e.printStackTrace();
            }
        }, "reader");
        reader.setDaemon(true); // so the program doesn't wait for input on exit
        reader.start();
        Thread.sleep(200);
        System.out.println("reader: " + reader.getState());
    }
}
reader: RUNNABLE

The thread does nothing and uses no CPU, yet its state is the same as that of a thread crunching numbers in a loop. So read RUNNABLE as “not waiting for anything the JVM knows about” rather than “working”. This matters when you troubleshoot: if a service hangs and every worker thread in the dump is RUNNABLE inside SocketInputStream.read or NioSocketImpl.read, the problem isn’t locking but a slow external service or a missing read timeout.

No Way Back from TERMINATED: Calling start() Twice

A thread in the TERMINATED state can’t be started again: calling start() a second time throws IllegalThreadStateException. start() is only allowed for a thread in NEW, so you get the same exception if you call it twice on a thread that is still running.

public class RestartExample {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> System.out.println("working"));
        t.start();
        t.join();
        System.out.println(t.getState());
        t.start(); // second start
    }
}
working
TERMINATED
Exception in thread "main" java.lang.IllegalThreadStateException
	at java.base/java.lang.Thread.start(Thread.java:...)
	at RestartExample.main(RestartExample.java:7)

To run the same work again, create a new Thread object with the same Runnable (or hand the task to a thread pool). A Thread object describes one run, not a reusable worker.

The isAlive() method is tied to the same two boundaries: it returns true when the thread’s state is neither NEW nor TERMINATED. isAlive() can’t tell “not started yet” from “already finished”; getState() can. Examples with isAlive() are in Thread.join() and isAlive().

Where to See Thread States: Thread Dumps (jstack)

A thread dump shows the state of every thread in a running JVM: run jstack <pid> or jcmd <pid> Thread.print. Each thread gets a java.lang.Thread.State: … line with the same enum value plus a note in parentheses explaining why the thread is waiting.

If you raise the holder pause in BlockedWaitingExample to a minute and take a dump, the relevant part looks roughly like this (trimmed; your addresses will differ):

"holder" #21 prio=5 ... waiting on condition
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(...)
	- locked <0x0000000711c0a1b8> (a java.lang.Object)

"blocked" #22 prio=5 ... waiting for monitor entry
   java.lang.Thread.State: BLOCKED (on object monitor)
	- waiting to lock <0x0000000711c0a1b8> (a java.lang.Object)

"waiter" #23 prio=5 ... in Object.wait()
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(...)
	at java.lang.Thread.join(...)

The notes in parentheses point to the cause: (sleeping) means Thread.sleep(), (on object monitor) means synchronized or wait(), and (parking) means LockSupport.park() — that is, ReentrantLock, queues and the rest of java.util.concurrent. You can also see that holder holds the monitor blocked is waiting for: the object address is the same. How to spot a deadlock in a dump is shown in Deadlock in Java.

Virtual Thread States (Java 21)

Virtual threads, introduced in Java 21, use the same Thread.State enum and the same getState() method; there are no extra values for them. A virtual thread in Thread.sleep() is TIMED_WAITING, in join() it’s WAITING, and once finished it’s TERMINATED.

public class VirtualStateExample {
    public static void main(String[] args) throws InterruptedException {
        Thread vt = Thread.ofVirtual().unstarted(() -> {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        });
        System.out.println(vt.isVirtual() + " " + vt.getState());
        vt.start();
        Thread.sleep(100);
        System.out.println(vt.getState());
        vt.join();
        System.out.println(vt.getState());
    }
}
true NEW
TIMED_WAITING
TERMINATED

One noticeable difference concerns network I/O. A virtual thread waiting for data from a socket is unmounted from its carrier thread and parked, so getState() usually reports WAITING, not RUNNABLE as for the platform thread in the blocking I/O section. If you compare thread dumps before and after moving to virtual threads, the “missing” RUNNABLE threads in read() are expected behavior, not a sign of trouble.

Frequently Asked Questions

Why is there no separate RUNNING state in Thread.State?

Because the operating system scheduler, not the JVM, decides which thread is on a CPU. A thread can gain and lose the processor thousands of times per second, and tracking that would be expensive and useless: by the time you read RUNNING, it would already be out of date. So Java merges “ready” and “running” into RUNNABLE. Where the term Running comes from is explained in the tip in The 6 Thread.State values.

What state is a thread in while it waits on ReentrantLock.lock()?

WAITING, not BLOCKED, even though logically it’s also waiting for a lock. BLOCKED only happens while waiting for a synchronized monitor. Locks from java.util.concurrent.locks are built on LockSupport.park(), which gives WAITING (or TIMED_WAITING for tryLock(timeout)). In a thread dump such a thread is marked (parking).

Can a thread go from NEW straight to TERMINATED?

No. The only way out of NEW is start(), which moves the thread to RUNNABLE, and only from there can it terminate. A Thread object whose start() is never called stays in NEW forever; its run() method never executes, and the object itself is garbage-collected like any other object.

What state is main in while it waits on t.join()?

WAITING, or TIMED_WAITING for t.join(1000). It uses no CPU meanwhile and returns to RUNNABLE when t finishes, the timeout expires, or main is interrupted with interrupt(). More in Thread.join() and isAlive().

Comments

Please log in or register to have a possibility to add comment.