In the past, it was common for a C++ developer to write programs by using threading libraries or native threading mechanisms (for example pthread, a Windows thread). Since C++11, this has changed drastically and concurrency is another big feature that was added that goes in the direction of a self-consistent language. The two new features we'll look at in this recipe are std::thread and std::async.
Understanding concurrency
How to do it...
In this section, we'll learn how to use std::thread with a basic scenario (create and join) and how to pass and receive parameters to it:
- std::thread: By using the basic thread methods, create and join, write the following code:
#include <iostream>
#include <...