Advertisement

Concurrency

  • Peter Van Weert
  • Marc Gregoire
Chapter

Abstract

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); });

Copyright information

© Peter Van Weert and Marc Gregoire 2019

Authors and Affiliations

  • Peter Van Weert
    • 1
  • Marc Gregoire
    • 2
  1. 1.Kessel-LoBelgium
  2. 2.MeldertBelgium

Personalised recommendations