title: 2 threads left hanging waiting on QWaitCondition in spite of wakeAll calls
body: <p>I have threaded iterative generation of some geometries. I use VTK for rendering. After each iteration I would like to display (render) the current progress. My approach works as expected until the last 2 threads are left hanging waiting for QWaitCondition. They are blocked, even though their status in QWaitCondition's queue is wokenUp (inspected through debugger). I suspect that number of 2 threads is somehow connected with my processor's 4 cores.</p>
  
  <p>Simplified code is below. What am I doing wrong and how to fix it?</p>
  
  <pre><code>class Logic
  {
      QMutex threadLock, renderLock;
      //SOLUTION: renderLock should be per thread, not global like this!
      QWaitCondition wc;
      bool render;
      ...
  }
  
  Logic::Logic()
  {
      ...
      renderLock.lock(); //needs to be locked for QWaitCondition
  }
  
  void Logic::timerProc()
  {
      static int count=0;
      if (render||count&gt;10) //render wanted or not rendered in a while
      {
          threadLock.lock();
          vtkRenderWindow-&gt;Render();
          render=false;
          count=0;
          wc.wakeAll();
          threadLock.unlock();
      }
      else
          count++;
  }
  
  double Logic::makeMesh(int meshIndex)
  {
      while (notFinished)
      {
          ...(calculate g)
          threadLock.lock(); //lock scene
          mesh[meshIndex]-&gt;setGeometry(g);
          render=true;
          threadLock.unlock();
          wc.wait(&amp;renderLock); //wait until rendered
      }
      return g.size;
  }
  
  void Logic::makeAllMeshes()
  {
      vector&lt;QFuture&lt;double&gt;&gt; r;
      for (int i=0; i&lt;meshes.size(); i++)
      {       
          QFuture&lt;double&gt; future = QtConcurrent::run&lt;double&gt;(this, &amp;Logic::makeMesh, i);
          r.push_back(future);
      }
  
      while(any r is not finished)
          QApplication::processEvents(); //give timer a chance
  }
  </code></pre>