O'Reilly logo

C++17 Standard Library Quick Reference: A Pocket Guide to Data Structures, Algorithms, and Functions by Marc Gregoire, Peter Van Weert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Peter Van Weert and Marc Gregoire 2019
Peter Van Weert and Marc GregoireC++17 Standard Library Quick Referencehttps://doi.org/10.1007/978-1-4842-4923-9_7

7. Concurrency

Peter Van Weert1  and Marc Gregoire2
(1)
Kessel-Lo, Belgium
(2)
Meldert, Belgium
 

Threads <thread>

Launching a New Thread

To run any function pointer, functor, or lambda expression in a new thread of execution, pass it to the constructor of std::thread, along with any number of arguments. For example, these two lines are functionally equivalent:
std::thread worker1(my_callable, "arg", anotherArg);
std::thread worker2([=] { my_callable("arg", anotherArg); });

The given callable with its arguments is invoked in a newly launched thread of execution prior to returning from the thread’s constructor. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required