Is there an implicit memory barrier with synchronized-with relationship on thread::join?
I have a code at work that starts multiple threads that doing some operations and if any of them fail they set the shared variable to false . Then main thread joins all the worker threads. Simulation of this looks roughly like this (I commented out the possible fix which I don't know if it's needed): #include <thread> #include <atomic> #include <vector> #include <iostream> #include <cassert> using namespace std; //atomic_bool success = true; bool success = true; int main() { vector<thread> v; for (int i = 0; i < 10; ++i) { v.emplace_back([=] { if (i == 5 || i == 6) { //success.store(false,