Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
This std::thread examples shows the code and screen output of two threads counting down. Below it, the code is discussed in more detail.
#include <iostream> |
Screen output:
##12: : 10 |
Note the following about the code:
##12: : 10 |
This example is checked for errors in helgrind example 1: two counting threads, where helgrind is shown to detect race conditions.
The next example, std::thread example 2: two counting threads using std::mutex demonstrates how to use std::mutexes to share std::cout nicely.
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.