← Back to libraryQuestion 31 of 273
JavaIntermediate

Thread Lifecycle States

📖 Detailed Explanation:

A thread moves through several states: NEW (created but not started), RUNNABLE (ready to run or running), BLOCKED (waiting for a monitor lock), WAITING (waiting for another thread or notification), TIMED_WAITING (sleeping), and TERMINATED (finished). Understanding state transitions is crucial for debugging multithreaded applications.

🌍 Real-World Example:

NEW: Baby born. RUNNABLE: Baby awake and playing. BLOCKED: Baby waiting for mom. WAITING: Baby sleeping. TERMINATED: Baby grows into adult.

🎯 Scenario-Based Interview Question:

What is the difference between the 'start()' and 'run()' methods of a Thread? What happens if you call run() directly?