InterviewSolution
| 1. |
Thread Life Cycle 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. A diagram to understand the states in the thread life cycle is GIVEN below: The 5 states in a thread life cycle are:
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.
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.
If the thread scheduler has selected a thread and it is CURRENTLY running, then it is in the running state.
When a thread is not ELIGIBLE to run but still ALIVE, then it is in the blocked state.
When the run() method of a thread exits, then it is in the terminated state. |
|