title: Counting seconds in Java
body: <p>I'm trying to make a simple applet that will just count out seconds.
  For some reason, my code starts at "2" and counts in even numbers.
  After looking closely at my code, I can't see why it would do this! Could someone help me out please?</p>
  
  <pre><code>import java.applet.Applet;
  import java.awt.Graphics;
  
  public class Main extends Applet implements Runnable {
  
      int seconds= 0;
      public void init() {
          setSize(50, 50);
          Thread thread = new Thread(this);
          thread.start();
          Thread timer = new Thread(this);
          timer.start();
      }
  
      public void run() {
  
          while (true) {
              try {
                  System.out.println(String.valueOf(seconds));
                  seconds= seconds +1;
                  Thread.sleep(1000);
              } catch (InterruptedException e1) {
                  e1.printStackTrace();
              }
  
              repaint();
              try {
                  Thread.sleep(17);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
      }   
  
      public void paint(Graphics g){
      g.drawString(String.valueOf(seconds), 25, 25);
      }
  }
  </code></pre>