In a simple server-client mechanism I'm writing, the server stores a set of key-value mappings in an STL map. For talking to multiple clients, a separate thread is created for each, and I've passed the map to the threads using std::ref (I need a common keystore). While this works, is it possible that:
1) If two clients communicate exactly at the same time, then the two threads will try to modify the map at the same time?
2) In this case, what would happen?
3) What possibly could I do to avoid anything bad?