4 ms·
Joinable thread and non-joinable one are very different in usage. It is rather appropriate to use a different class.
by fpoling 6y ago
Joinable thread and non-joinable one are very different in usage. It is rather appropriate to use a different class.
- masklinn 6y agostd::thread are already joinable (and that's their default state), and jthreads can be detached. The one difference between std::thread and jthread is that std::thread terminates on destruction, while jthread joins. That could easily be a ctor parameter (as well as "detach on destruction" as a third option).
- dataflow 6y ago> Joinable thread and non-joinable one are very different in usage. What is the usage of a "non-joinable" thread in the first place? I mentioned in a comment that that concept itself seems like a code smell to me, and certainly not something that should be the default. See here to read why: https://news.ycombinator.com/item?id=26142754 https://news.ycombinator.com/item?id=26142754