Another Windows synchronization object is semaphore. Semaphore works as a narrow gate, which a certain number of threads can pass through at any instant of time. We will use our previous example again with slight changes to demonstrate various approaches with different synchronization objects and techniques while achieving the same results.
Make sure Visual Studio is up and running.
How to do it...
Now, let's create our program and explain its structure.
- Create a new empty C++ Windows application named
- Open Solution Explorer and right-click on Header file. Add the existing header file used in Chapter 1, Introduction to C++ Concepts and Features, named
- Open Solution Explorer and right-click ...