Will a calling thread see modifications to local variables after thread.join()?
问题 In the simplest possible example, let's say I have a function that starts a thread, which in turn sets the value of a local variable to true. We join the thread, then leave the function. bool func() { bool b = false; std::thread t([&]() { b = true; }); t.join(); return b; } Will this function return true, or is the behavior undefined? 回答1: Yes, it must return true. [thread.thread.member] void join(); 4 Effects : Blocks until the thread represented by *this has completed. 5 Synchronization :