title: multiple tasks for a few threads
body: <p>I'm using the thread library on c++11 to do some things. The problem is that i have a limited number of threads (4).</p>
  
  <p>I would know how to deal with it:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;thread&gt;
  
  #define NUMBER_OF_THREADS 4
  
  void foo(const std::string&amp; astring)
  {
      std::cout &lt;&lt; astring &lt;&lt; std::endl;
  }
  
  int main()
  {
      std::vector&lt;std::string&gt; list_of_strings(100);
      // values assigned
      std::vector&lt;std::thread&gt; list_of_threads(NUMBER_OF_THREADS);
      for(std::vector&lt;std::string&gt;::const_iterator it_string = list_of_strings.begin() ; it_string != list_of_strings.end() ; ++it_string)
      {
          bool check = false;
          unsigned int = 0;
          while(!check) // loop which assigns the next task to the first thread ready.
          {
              if( check = list_of_threads.at(i).ISFREE()) // how to do ?
              {
                  list_of_threads.at(i) = thread(&amp;foo,*it_string);
              }
              else
              {
                  i = (i + 1) % NUMBER_OF_THREADS;
              }
          }
      }
      for(std::vector&lt;std::thread&gt;::iterator it = list_of_threads.begin() ; it != list_of_threads.end() ; ++it)
          it-&gt;join(); // the main thread is waiting for all threads before closing.
      return 0;
  }
  </code></pre>
  
  <p>But i don't know how to check if the thread is ready for a new task or not. Any idea ?</p>