September 2017
Beginner to intermediate
384 pages
8h 4m
English
The following command helps you compile the program:
g++ main.cpp -std=c++17 -lpthread
In the previous command, -std=c++17 instructs the C++ compiler to enable the C++17 features; however, the program will compile on any C++ compiler that supports C++11, and you just need to replace c++17 with c++11.
The output of the program will look like this:

All the numbers starting with 140 in the preceding screenshot are thread IDs. Since we created three threads, three unique thread IDs are assigned respectively by the pthread library. If you are really keen on finding the thread IDs assigned by the operating system, you will ...