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