title: Java wait for Timer thread to complete
body: <p>I am new in Java multithreading, i just implemented Timer class to execute method on specific interval time. </p>
  
  <p>here my code :</p>
  
  <pre><code>public static void main(String[] args) {
  
      Timer timer = new Timer();
      timer.schedule(new MyTimerTask(), 3000);
  
      //execute this code after timer finished
      System.out.println("finish");
  }
  
  private static class MyTimerTask extends TimerTask {
  
      @Override
      public void run() {
          System.out.println("inside timer");
      }
  
  }
  </code></pre>
  
  <p>but the output like this :</p>
  
  <pre><code>finish
  inside timer
  </code></pre>
  
  <p>I want it like this :</p>
  
  <pre><code>inside timer
  finish
  </code></pre>
  
  <p>so how to wait timer thread to complete and then continue execute code in main thread? any suggestion?</p>