title: How to create an array of thread objects in C++11?
body: <p>I want to learn how to create multiple threads with the new C++ standard library and store their handles into an array.<br>
  How can I start a thread?<br>
  The examples that I saw start a thread with the constructor, but if I use array, I cannot call the constructor.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  
  void exec(int n){
      std::cout &lt;&lt; "thread " &lt;&lt; n &lt;&lt; std::endl;
  }
  
  int main(int argc, char* argv[]){
  
      std::thread myThreads[4];
  
      for (int i=0; i&lt;4; i++){
          //myThreads[i].start(exec, i); //?? create, start, run
          //new (&amp;myThreads[i]) std::thread(exec, i); //I tried it and it seems to work, but it looks like a bad design or an anti-pattern.
      }
      for (int i=0; i&lt;4; i++){
          myThreads[i].join();
      }
  
  }
  </code></pre>