title: How to join one thread with other in java?
body: <p>I have one main thread that starts 10 other threads. I want that the main thread will be finished only after all other threads stopped. So should I call join() on other 10 threads before starting or after starting them. For instance:</p>
  
  <pre><code>// in the main() method of Main thread
  Thread [] threads = new Thread[10];
  for(int i = 0; i &lt; 10; i++) {
      // ParserThread() is a runnable thread
      threads[i] = new Thread(new ParserThread());
      threads[i].join();
      threads[i].start();
  }
  System.out.println("All threads have been finished"); // line no. 9
  </code></pre>
  
  <ol>
  <li>So as in the above example, should i call join() before start() or after start().</li>
  <li>Will the control returns to line no. 9 only after all the threads have finished.</li>
  <li>When the run method of any thread has been executed, then will that thread die or remain alive. If it will, the how to die all the threads when their run method has finished means when the control returns to line no. 9</li>
  </ol>