title: How to use Java.Util.Timer
body: <p>I want to make a simple program that counts seconds up until 100 using Java.Util.Timer
  The code below is the code I am using, however it simply prints all the numbers out at once without waiting a second between each one. How would I fix that? (Ordinarily I would use a thread.sleep but this is just proof of concept.)</p>
  
  <pre><code>import java.util.Timer;
  import java.util.TimerTask;
  
  public class Main {
      static Timer timer = new Timer();
      static int seconds = 0;
  
      public static void main(String[] agrs) {
  
          MyTimer();
  
      }
  
      public static void MyTimer() {
  
          TimerTask task;
  
          task = new TimerTask() {
              @Override
              public void run() { 
                  while (seconds &lt; 100) {
                      System.out.println("Seconds = " + seconds);
                      seconds++;
                  }
              }
          };
           timer.schedule(task, 0, 1000);
  
      }
  
  }}
  </code></pre>