title: redirect standard output to a file using multiple thread
body: <p>I tried to redirect standart output (cout) to a file, for debugging purposes</p>
  
  <pre><code>std::ofstream traceFile;
  traceFile.open("c:/path/file.txt");
  std::streambuf* fileBuff = traceFile.rdbuf();
  
  std::cout.rdbuf(fileBuff);
  
  std::cout &lt;&lt; std::unitbuff;
  
  std::cout &lt;&lt; "disk is written\n";
  </code></pre>
  
  <p>But calling cout from a new thread make the code stuck on a mutex. (xmtx.c 39: _Mtxlock()).</p>
  
  <p>Have you got an idea, how i could solve it?</p>
  
  <p>Thank you</p>