title: Is there a way to make the java timer fire a certain number of times, then stop?
body: <p>Ok, so I need a timer to fire X number of times, ie. 5 times, and I know how to make it all work, but I can't figure out this one problem. If there isn't just some invoked method, then maybe there's a different way to do something like that? but here's the code i'm working with;</p>
  
  <pre><code>int delay = 5000;
  ActionListener taskPerformer = new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
      //some action here
    }
  };
  
  new Timer(delay, taskPerformer).start();
  </code></pre>
  
  <p>(also, if theres anything wrong with this code, please tell me. Thanks!)</p>