title: Does a mutex unlock when it comes out of scope?
body: <p>Simple question - basically, do I have to unlock a mutex, or can I simply use the scope operators and the mutex will unlock automatically?</p>
  
  <p>ie:</p>
  
  <pre><code>{ 
      pthread_mutex_lock (&amp;myMutex); 
      sharedResource++; 
  } // my mutex is now unlocked?
  </code></pre>
  
  <p>or should I:</p>
  
  <pre><code>{ 
      pthread_mutex_lock (&amp;myMutex); 
      sharedResource++;
      pthread_mutex_unlock (&amp;myMutex);
  }
  </code></pre>