title: Why does the thread run only once?
body: <p>I'm trying to track the position of the mouse cursor and thus need to use a thread to continue tracking it. My thread is running only once. I'm guessing that I have missed something along the way. </p>
  
  <p>The code : </p>
  
  <p>mousePosition class</p>
  
  <pre><code>import java.awt.MouseInfo;
  import java.awt.Point;
  import java.util.Timer;
  
  public class mousePosition implements Runnable
  {
      static Point mouseLocation = MouseInfo.getPointerInfo().getLocation();
      static Timer t = new Timer();
      int x,y = 0;
  
  
      public void run()
      {
          try
          {
                  x = mouseLocation.x;
                  y = mouseLocation.y;
  
                  System.out.println("X:"+x+" Y:"+y+" at time "+System.currentTimeMillis());
          }
  
          catch(Exception e)
          {
              System.out.println("Exception caught : "+e);
          }
  
      }
  
  
  
  }
  </code></pre>
  
  <p>main class</p>
  
  <pre><code>public class threadRunner
  {
      public static void main(String[] args)
      {
          Thread t1 = new Thread(new mousePosition());
  
          t1.start();
  
      }
  
  }
  </code></pre>
  
  <p>Thank you for any help. I know that this question was asked before but I am still struggling to make it work. </p>