What are the different states of a threads lifecycle?
Submitted by: AdministratorFollowing are the different states of threads:
1. New - A thread is called in New state until the start() method is called for the object of that thread. The thread is not alive in this state.
2. Runnable - The thread is called in Runnable state after the start() method is called for the object of that thread. The thread may enter into the Runnable state from Running state. The thread is called alive in this state.
3. Running - The thread is called in Running state when the thread scheduler take it from the Runnable thread's pool.
4. Waiting/Blocked/Sleeping - In these states the thread is alive but it's not in Runnable state. A running thread is called in these states after wait() or sleep() method is called that thread or when the thread is blocked while waiting for I/O resources.
5. Dead - After the execution of run() method is complete then the thread is called in dead state. Once a thread is dead then it cannot be start again.
Submitted by: Administrator
1. New - A thread is called in New state until the start() method is called for the object of that thread. The thread is not alive in this state.
2. Runnable - The thread is called in Runnable state after the start() method is called for the object of that thread. The thread may enter into the Runnable state from Running state. The thread is called alive in this state.
3. Running - The thread is called in Running state when the thread scheduler take it from the Runnable thread's pool.
4. Waiting/Blocked/Sleeping - In these states the thread is alive but it's not in Runnable state. A running thread is called in these states after wait() or sleep() method is called that thread or when the thread is blocked while waiting for I/O resources.
5. Dead - After the execution of run() method is complete then the thread is called in dead state. Once a thread is dead then it cannot be start again.
Submitted by: Administrator
Read Online Java Multi-Threading Job Interview Questions And Answers
Top Java Multi-Threading Questions
☺ | Explain deadlock? |
☺ | What is the sleep() method Data type for the parameter? |
☺ | Explain the difference between preemptive scheduling and time slicing? |
☺ | How many threads at a time can access a monitor? |
☺ | Name the default thread at the time of starting the program? |
Top Java Programming Language Categories
☺ | Core Java Interview Questions. |
☺ | Hibernate Interview Questions. |
☺ | Advanced Java Interview Questions. |
☺ | IBM WebSphere Interview Questions. |
☺ | Spring Framework Interview Questions. |