An executing thread is in the running state.
When a thread in Java is executing, it is in the “Runnable” state. In the multithreading context of Java, a thread goes through different states in its lifecycle. The main states are:
- New: The thread is in this state before the start() method is called on it.
- Runnable: The thread is ready to run and is waiting for the CPU to execute it. When the thread scheduler picks it, it moves to the running state.
- Blocked: The thread is waiting for a monitor lock to enter a synchronized block/method or waiting for some I/O operation to complete.
- Waiting: The thread is in this state due to a call to the
wait()
method, and it is waiting for another thread to notify or notifyAll() to wake it up. - Timed Waiting: Similar to the waiting state, but with a specified waiting time. Threads enter this state due to methods like
sleep()
orjoin()
with a timeout. - Terminated: The thread has completed its execution or terminated due to an uncaught exception.
So, when a thread is actively executing its code, it is in the “Runnable” state.