title: Spawn multiple std::thread and reuse it
body: <p>I am a noob when it comes to threading and need some help / advice.
  First of all, can you check if my understanding is correct in the following code:</p>
  
  <pre><code>std::vector&lt;std::unique_ptr&lt;Object&gt;&gt; totalObjects(512);
  std::vector&lt;Object*&gt; objectsToUpdate(32);
  std::vector&lt;std::thread&gt; threadsPool(32);
  
  int nrObjectsToUpdate; //Varies between 1 and 32 for each update.
  
  findObjectsToUpdate(totalObjects, objectsToUpdate, nrObjectsToUpdate);
  
  for(int i = 0; i &lt; nrObjectsToUpdate; i++)
      threadsPool[i] = std::thread(objectsToUpdate[i]-&gt;updateTask1());
  
  //All tasks in this step must be completed before 
  //we can move on to the next, i.e. updateTask2();.
  for(int i = 0; i &lt; nrObjectsToUpdate; i++)
      threadsPool[i].join();
  
  for(int i = 0; i &lt; nrObjectsToUpdate; i++)
      threadsPool[i] = std::thread(objectsToUpdate[i]-&gt;updateTask2());
  
  for(int i = 0; i &lt; nrObjectsToUpdate; i++)
      threadsPool[i].join();
  </code></pre>
  
  <p>Should I spawn one thread for each updateTask1() and updateTask2()?
  For each update, do I need to create std::thread() all over again? or can I simply reuse it again with some member function?
  If I create threads for updateTask1(), is it possible to reuse all thread objects for updateTask2()?, i.e. switching function pointer with some std::thread member function?</p>
  
  <p>Let us say that we create 100 threads and we have a quadcore CPU(4 cores), 
  will all the CPU cores be busy until all the threads is completed?
  I know at least that 4 cores means 4 threads.</p>
  
  <p>Grateful for all the help and explanations that can be given.</p>