I am newbie to c++ multithreading programming. I read some documents and some articles from web and notice the fact that multi find operation at the same time in STL unordered_map are allowed, while multi insert operation are not allowed.
I have two questions:
Could find operation and insert operation at the same time be allowed? For example,
std::string x = "jim"; std::string y = "marry"; std::unordered_map<std::string, int> map; // Thead A executes below code auto iterator = map.find(x); // Thread B executes below code map.insert(std::make_pair(y, "value"));
Please notice here x and y are not the same.
What if x and y are the same? What would happen if we find the key and insert the same key in the meanwhile?
Thanks guys if you answer this question with the reference where you get this knowledge.