title: Very simple method with QtConcurrentRun and mutex sometimes gives segmentation fault
body: <p>I want to know what is wrong with this code. Sometimes I get sementation fault, sometimes not. This is a problem that I have in a greater piece of software, the idea is that just one thread at the same time is executing the method MyClass::print. Even with this simple example, it fail with segmentation fault. What is wrong in the code? How I can solve the problem? </p>
  
  <p>Thanks!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;QMutex&gt;
  #include &lt;QtConcurrentRun&gt;
  
  class MyClass : QThread {
  public:
      void print(std::string str) {
          mutex.lock();
          std::cout &lt;&lt; "In some thread: " &lt;&lt;  str &lt;&lt; "\n";
          mutex.unlock();
      }
  
  private:
      QMutex mutex;
  
  };
  
  int main() {
  
      MyClass myCl;
  
      for(int i=0; i &lt; 10; i++) {
          QtConcurrent::run(&amp;myCl, &amp;MyClass::print,std::string("bla"));
      }
  
  }
  </code></pre>