Is copying from a std::map or std::set thread-safe?
问题 I know that multi-thread read access to an std::se t or std::map is safe, but what about doing copy operations like std::map<int, int> node_info; int node = 2; int node_value; if (node_info.find(node) != node_info.end()) current_val = map_of_val[node].front(); I lock the maps when I am using .push() or .pop() for synchronized access, but my code is behaving erratically and I would like to know if know if this is causing instability. 回答1: Locking on push() and pop() isn't enough. If one thread