title: How do I make threads run sequentially instead of concurrently?
body: <p>For example I want each thread to not start running until the previous one has completed, is there a flag, something like <code>thread.isRunning()</code>?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;thread&gt;
  using namespace std;
  
  void hello() {
      cout &lt;&lt; "thread id: " &lt;&lt; this_thread::get_id() &lt;&lt; endl;
  }
  
  int main() {
  
      vector&lt;thread&gt; threads;
  
      for (int i = 0; i &lt; 5; ++i)
          threads.push_back(thread(hello));
  
  
      for (thread&amp; thr : threads)
          thr.join();
  
      cin.get();
      return 0;
  }
  </code></pre>
  
  <p>I know that the threads are meant to run concurrently, but <em>what if</em> I want to control the order?</p>