title: Does std::thread library in C++ support nested threading?
body: <p>I want to create nested threads in C++ using <code>std::thread</code> library like this.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;thread&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  void innerfunc(int inp)
  {
      cout &lt;&lt; inp &lt;&lt; endl;
  }
  void outerfunc(int inp)
  {
      thread * threads = new thread[inp];
      for (int i = 0; i &lt; inp; i++)
          threads[i] = thread(innerfunc, i);
      for (int i = 0; i &lt; inp; i++)
          threads[i].join();
      delete[] threads;
  }
  int main()
  {
       int inp = 0;
       thread t1 = thread(outerfunc,2);
       thread t2 = thread(outerfunc,3);
       t1.join();
       t2.join();
  }
  </code></pre>
  
  <p>Can I do this safely? I am worried whether <code>join()</code> works correctly.</p>