Basic thread management
We are going to implement the thread class to give the user a sense of abstraction of the thread's implementation, which is useful for a specific problem. We will implement another helper class
CLock, which we will use for synchronized execution if needed.
Make sure that Visual Studio is up and running.
How to do it...
Now, let's create our program and explain its structure using the following steps:
- Create a new empty C++ Console application named
- Add a new header file named
- Add the following code to it:
#ifndef _CTHREAD_ #define _CTHREAD_ #include <windows.h> #define STATE_RUNNING 0x0001 #define STATE_READY 0x0002 #define STATE_BLOCKED 0x0004 #define STATE_ALIVE 0x0008 #define STATE_ASYNC 0x0010 ...