title: how avoid freezing other threads when one thread locks a big map
body: <p>How to avoid freezing other threads which try to access the same map that is being locked by current thread? see below code:</p>
  
  <pre><code>           //pseudo code
             std::map&lt;string, CSomeClass* &gt; gBigMap;
             void AccessMapForWriting(string aString){
                   pthread_mutex_lock(&amp;MapLock);
  
                   CSomeClass* obj = gBigMap[aString];
                   if (obj){
                         gBigMap.erase(aString);
  
                         delete obj;
                         obj = NULL;
                   }
  
  
                   pthread_mutex_unlock(&amp;MapLock);
             }
  
             void AccessMapForReading(string aString){
                   pthread_mutex_lock(&amp;MapLock);
                   CSomeClass* obj = gBigMap[aString];
  
                   //below code consumes much time
                   //sometimes it even sleeps for milliseconds
                   if (obj){
                       obj-&gt;TimeConsumingOperation();
                   }
  
                   pthread_mutex_unlock(&amp;MapLock);
             }
  
             //other threads will also call 
             //the same function -- AccessMap
             void *OtherThreadFunc(void *){
                   //call AccessMap here
             }
  </code></pre>