title: thread.join() problem in java
body: <p><strong>My Code</strong></p>
  
  <pre><code>public class Main {
  
      public static void main(String[] args)throws Exception {
          Thread thread1=new Thread(new Runnable()
          {
              public void run()
              {
                  System.out.println("Thread1");
              }
          });
          thread1.join();
          thread1.start();
          for (int i = 0; i &lt; 1000; i++) {
              System.out.println(i);
          }
      }
  
  }
  </code></pre>
  
  <p>Sometimes "Thread1" gets printed even before all the numbers get printed. Any reason for that? Shouldn't Thread1 should wait until main thread gets completed?</p>