Thursday, January 14, 2021

What are the different states of a thread and when do the state transitions occur?

Here we examine the life cycle of a thread and how it transitions into the next state:
A simplified approach

Like most things, threads have a cycle of being born and eventually dying! As yet, we don't know whether they achieve supreme consciousness or re-incarnate ... that is a topic for philosophers:)

We can draw some similarities to humans in that they are born (new), learn to crawl (runnable but not running), walking, then running. In our lives we learn and interact based on experience and the information we are given. We experience blockages or periods where we have to wait for the next event to happen and along the road we sometimes pause and relinquish control to another person or group.

At the end of it all we die or terminate - sad, but true that when the work is done then it's all over! We stop being consumers and for a thread this applies to using the CPU.

Let's summarize in the table below for quick reference:




No comments:

Post a Comment