Thread Lifecycle

New, Runnable, Running, Waiting, Terminated

Interview Relevant: Thread states are frequently asked

Thread Lifecycle

NEW → RUNNABLE → RUNNING → WAITING/BLOCKED → TERMINATED
        

Code Examples

Thread state check

java
1
2Thread t = new Thread(() -> {});
3System.out.println(t.getState());
4          

Use Cases

  • Debugging

Common Mistakes to Avoid

  • Confusing RUNNABLE and RUNNING