title: main thread waits for std::async to complete
body: <p>I am using <code>std::async</code> to create a thread, I want this new thread should execute separately and main thread should not wait for it. But here when I call std::async, a new thread is created but main thread is waiting for completion of <code>fun()</code>. I want main thread to execute parallely without waiting for <code>fun()</code> to complete. How should I do that?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;future&gt;
  using namespace std;
  
  
  
  void printid()
  {
     cout &lt;&lt; "Thread id is:" &lt;&lt; this_thread::get_id() &lt;&lt; endl;
  }
  
  void fun(void *obj)
  {
  
     cout&lt;&lt;"Entry"&lt;&lt;endl;
     printid();
     Sleep(10000);
     cout&lt;&lt;"Exit"&lt;&lt;endl;
  }
  
  
  int main()
  {
      cout&lt;&lt;"Hello"&lt;&lt;endl;
      printid();
      std::async(std::launch::async, fun, nullptr);
      cout &lt;&lt; "After call" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I am getting output:</p>
  
  <pre><code>Hello
  Thread id is:22832
  Entry
  Thread id is:13156
  Exit
  After call
  </code></pre>