How it works...

Let's analyze the previous four programs:

  1. std::thread: The following program shows basic thread usage for create and join:

There's nothing really complex in this first test. std::thread was initialized with a function through the uniform initialization and joined (waiting for the thread to be completed). The thread would accept a function object:

struct threadFunction {    int speed;    void operator ()();}std::thread t(threadFunction);
  1. std::thread: Create and join a thread, passing a parameter and getting a result:

This second ...

Get C++ System Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.