title: thread.join() not consequent
body: <p>I'm working with threads, the worker function is the following: </p>
  
  <pre><code>void threadDoIt(tso* tso0){
      while (true){
          task t = tso0-&gt;getNextTask();
          if (t.getState() == empty){
              break;
          }
          else {
              t.execute();
              TAL::taskExecuted(t);
          }
      }
  }
  
  /*...*/
  
  vector&lt;thread&gt; threads;
  
  for (int i = 0; i &lt; cpus; i++){
      threads.push_back(thread(threadDoIt, tsos.at(i)));
  }
  
  for (int i = 0; i &lt; threads.size(); i++){
      threads[i].join();
  }
  </code></pre>
  
  <p>and I experience that sometimes all the tasks are executed, but sometimes not. It seems like there's a problem with the joining method. Any idea?</p>