c++multithreadingsemanticsstdasync

How does std::async automatically join threads?


The c++ 11 std::async is a great thread abstraction, but every thread has to be joined so how does std::async join threads without exposing it to the user?


Solution

  • std::async doesn't join threads. Instead, it initialized threads that are detatched from a thread object. These execution of these threads is independent of the process that created them and their resources are freed by the OS once they exit.