Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 26s8 days 9 hours 54 minutes 26 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 26s8 days 9 hours 54 minutes 26 seconds.

Sign in to watch this lesson
Threads and Their Lifetimes · 4:16
A std::thread starts running the moment it is constructed, and before its handle is destroyed you must join or detach it, or the program terminates. Following C++ Concurrency in Action, we watch the real abort on a Mac, see a detached thread read a dead stack frame (caught by AddressSanitizer), and make the join automatic with RAII, from thread_guard to a joining wrapper and C++20's std::jthread.