title: Why is the usage of mutex correct in C++?
body: <p>I was asked a question about mutex before, the code works fine, but I am confused about this result：</p>
  
  <pre><code>::std::mutex s_mutex;
  void funcA()
  {
      s_mutex.lock();
  
      printf( "funcA \n" );
  
      s_mutex.unlock();
  }
  
  void funcB()
  {
      s_mutex.lock();
  
      funcA();
  
      printf( "funcB \n" );
  
      s_mutex.unlock();
  }
  
  int main()
  {
      funcB();
  
      return 0;
  }
  </code></pre>
  
  <p>It works fine and print what I did not etxpect：</p>
  
  <pre><code>funcA 
  funcB 
  </code></pre>
  
  <p>But why? This func is called in main thread and seems to call lock twice.</p>