title: What is the difference between two join statements in the code?
body: <p>In the below code, there are two joins (of course one is commented). I would like to know what is the difference between 
  when join is executed before the loop and when join is executed after the loop?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  using namespace std;
  
  void ThreadFunction();
  
  int main()
  {
      thread ThreadFunctionObj(ThreadFunction);
      //ThreadFunctionObj.join();
      for (int j=0;j&lt;10;++j)
      {
          cout &lt;&lt; "\tj = " &lt;&lt; j  &lt;&lt; endl;
      }
      ThreadFunctionObj.join();
      return 0;
  }
  
  void ThreadFunction()
  {
      for (int i=0;i&lt;10;++i)
      {
          cout &lt;&lt; "i = " &lt;&lt; i  &lt;&lt; endl;
      }
  }
  </code></pre>