Java / Java Concurrency and Multi Threading in Java 17 and Java 21 Interview questions
What are the different states of a thread in Java?
A Java thread moves through a well-defined set of states, represented by the Thread.State enum, over its lifetime.
| State | Meaning |
| NEW | Thread object created but start() not yet called. |
| RUNNABLE | Executing or ready to run and waiting for CPU time from the scheduler. |
| BLOCKED | Waiting to acquire a monitor lock held by another thread. |
| WAITING | Waiting indefinitely for another thread's signal, e.g. via wait() or join() with no timeout. |
| TIMED_WAITING | Waiting for a bounded period, e.g. sleep(ms) or wait(ms). |
| TERMINATED | The thread's run() method has completed or exited via an uncaught exception. |
You can inspect a thread's current state at any time with thread.getState(), which is especially useful when diagnosing hangs from a thread dump.
More Related questions...