RUNNABLE State: Ready to Execute
You'll learn what happens when a thread moves to RUNNABLE state and how it interacts with the OS scheduler.
What RUNNABLE Really Means
When you call start() on a thread, it doesn't instantly begin executing your code. Instead, it enters the RUNNABLE state, which means the thread is eligible to run and is waiting for the operating system's scheduler to give it CPU time.
Think of RUNNABLE like standing in line at a busy coffee shop where there are multiple baristas. You're ready to order (your code is ready to execute), but you need to wait for an available barista (CPU core) to serve you. The scheduler decides which customer gets served next.
The Scheduler's Job
Once in RUNNABLE state, your thread is:
- Fully initialized and ready to execute
- Managed by the JVM's thread scheduler and ultimately the OS scheduler
- Competing with other RUNNABLE threads for CPU time
- May be actively executing or waiting for its next time slice
This is why RUNNABLE is somewhat misleadingly named—it doesn't mean "currently running," it means "ready to run or actively running." From Java's perspective, both states are identical.
The Transition
Thread t = new Thread(() -> System.out.println("Hello"));
// t is in NEW state
t.start();
// t is now in RUNNABLE state, waiting for CPU time
The moment start() returns, your thread is RUNNABLE. The scheduler will eventually allocate CPU time, at which point the run() method begins executing.
Key Takeaway: RUNNABLE means the thread is ready to execute and is in the hands of the scheduler—it may be actively running or waiting for its turn on the CPU.