InterviewSolution
| 1. |
States of a Thread in Java |
|
Answer» The thread LIFE cycle in Java CONTAINS 5 states. This means that the thread can be in any of these 5 states. The 5 states in a thread life cycle are DEMONSTRATED with the help of a diagram as follows: 1. New When an instance of the thread class has been created but the start() method is not invoked, then the thread is in the new state. 2. RUNNABLE When the start() method has been invoked but the thread scheduler has not selected the thread for execution, then the thread is in the runnable state. 3. Running If the thread scheduler has selected a thread and it is currently running, then it is in the running state. 4. Blocked (Non-runnable) When a thread is not eligible to RUN but still alive, then it is in the blocked state. 5. Terminated When the run() method of a thread exits, then it is in the terminated state. |
|