3 ms·
With the caveat that the destructor crashes your program if you neither join nor explicitly detach the thread.
by abjKT26nO8 7y ago
With the caveat that the destructor crashes your program if you neither join nor explicitly detach the thread.
- ncmncm 7y agoBut, don't detach the thread.
- pjmlp 7y agoC++20 has apparently a fix for it with std::jthread, though. With all possible the learnings from Java, .NET, Erlang, TBB, Concurrency Runtime, and yet ISO C++ did not manage to get a proper concurrency story, and it full of traps like the one you mention. Another one is std::async, which might actually be synchronous, depending on a set of factors.