Are std::map and std::set thread-safe? <p>I have a question: Are std::map and std::set thread-safe? I use this collections on my multithread applications and sometimes map and set works worng. </p> <p>Thanks!</p> <p><strong>upd. My code:</strong></p> <pre><code>std::map&lt;int, unsigned long&gt; ClientTable; int sendulong(int socket, char * data) //&lt;--- Many threads uses this function { write(socket, ClientTable[socket]); //&lt;--- ClientTable[[socket] &lt;-- using of map } </code></pre> <p>How can i fix this code for thread safety? Thanks!</p>