Sunday, January 19, 2025
HomeProgrammingLife cycle of a Thread

Life cycle of a Thread

The life cycle of a thread in programming consists of several distinct states: New, Runnable, Running, Blocked, and Terminated. A thread begins in the New state when it is created but hasn’t started yet. Once the start() method is called, it moves to the Runnable state, where it is ready to run but waits for CPU time. When the CPU allocates time, the thread enters the Running state and executes. If it encounters a resource delay or synchronization block, it transitions to the Blocked state. After completing its execution or being stopped, the thread reaches the Terminated state, signaling the end of its life cycle.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x