Thread Lifetime Management: Warnings and Tips
Some caveats and tips on the lifetime of threads in C++ coming our way...
Warnings
âš The Challenge of
detach
: Of course we can uset.detach()
instead oft.join()
in the last program. The threadt
is not joinable anymore; therefore, its destructor didn’t callstd::terminate
. But now, we have another issue. The program behavior is undefined because the main program may complete before the ...