Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
A basic Windows application will start with a single thread. The function call to request that Windows create a child thread is CreateThread(). This call takes the parameters shown in Table 6.1.
| Parameter Type | Comment |
|---|---|
| LPTHREADATTRIBUTES | The security attributes of the thread; a discussion of this is outside the scope of this text. However, passing zero will suffice for the purposes of creating child threads. |
| SIZE_T | The stack size for the thread. The default is for each thread to get 1MB of stack space. A thread created using a POSIX API would have its stack size provided by a separate attributes structure. |
| LPTHREAD_START_ROUTINE | The address of the function that the thread will execute. |
| LPVOID | The parameters that are to be passed to the thread. |
| DWORD | Whether the thread should be created in a suspended state. A suspended thread needs to be started by a call to the ResumeThread() function. |
| LPDWORD | A pointer to a variable where the thread ID can be written. |