Speaking of threads...

Throughout this entire chapter, we've been using the word "thread" without ever defining exactly what we mean by it; and you've probably noticed that many of our multithreaded code examples have used the class type std::thread and the namespace std::this_thread without much explanation. We've been focusing on how to synchronize behavior between different threads of execution, but so far we have glossed over exactly who is doing the executing!

To put it another way: When execution reaches the expression mtx.lock(), where mtx is a locked mutex, the semantics of std::mutex say that the current thread of execution should block and wait. While that thread is blocked, what is happening? Our C++ program is still "in charge" ...

Get Mastering the C++17 STL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.