std::thread::join (3) - Linux Manuals
void join(); (since C++11)
Blocks the current thread until the thread identified by *this finishes its execution.
The completion of the thread identified by *this synchronizes with the corresponding successful return from join().
No synchronization is performed on *this itself. Concurrently calling join() on the same std::thread object from multiple threads constitutes a data race that results in undefined behavior.
joinable() is false
std::system_error if an error occurs.
* resource_deadlock_would_occur if this->get_id() == std::this_thread::get_id() (deadlock detected)
* no_such_process if the thread is not valid
* invalid_argument if joinable() is false
// Run this code
* C++11 standard (ISO/IEC 14882:2011):
detach (public member function)
joinable (public member function)