So far, I’ve explained how to implement a thread function and how to have the system create a thread to execute that function. In this section, we’ll look at how the system pulls this off.
Figure 6-1 shows what the system must do to create and initialize a thread.
Figure 6-1. How a thread is created and initialized
Let’s look closely at this figure to understand exactly what’s going on. A call to
CreateThread causes the system to create a thread kernel object. This object has an initial usage count of
2. (The thread kernel object is not destroyed until the thread stops running and the handle returned from
CreateThread is closed.) ...