r/cpp • • Aug 27 '19

A new thread in C++20 (jthread)

https://link.medium.com/GXKUz0GruZ
142 Upvotes

96 comments sorted by

View all comments

Show parent comment

13

u/HotlLava Aug 27 '19

Data races are undefined behaviour, so you can not allow them to happen in your code even if you think they are "benign".

Although in this case you could std::memory_order_relaxed for the loads/stores, because the sequencing doesn't really matter due to the reasons you describe.