title: How do you repeatedly call a Thread in Java?
body: <p>I want a thread to execute in the background every 500 milliseconds. To do that, I extended a Thread, implemented ActionListener and put the class that I extended into a Timer. The Timer calls run() every 500 milliseconds. However, my whole Swing GUI freezes up when this thread is downloading stuff from the Internet. I want it to run in the background, without freezing up the GUI while it waits for IO to finish. I also the downloader to finish downloading before we wait 500 milliseconds.</p>
  
  <p>gogogo() is called to initialize the whole process:</p>
  
  <pre><code>public final class Downloader extends Thread implements ActionListener
  {
  public static void gogogo()
  {
      t= new Downloader();
      new Timer(500, (ActionListener) t).start();
  
  }
  
  public void run() 
  {
      doStuff(); //the code that i want repeatedly called
  }
  
  public void actionPerformed(ActionEvent e) 
  {
      run();
  }
  }
  </code></pre>