title: Java Timer Every X Seconds
body: <p>So, I basically need a command to run every 5 seconds, but the Timer doesn't work...
  I tried so many different methods,
  The only thing that works is the Thread.sleep(Milliseconds);
  But that causes my whole game to stop working...
  If I try using a timer, for example:</p>
  
  <pre><code>Timer timer = new Timer(1000, new ActionListener(){
              @Override
              public void actionPerformed(ActionEvent e) {
                  System.out.println("Hey");
  
              }
          });
          timer.setRepeats(true);
          timer.setCoalesce(true);
          timer.start();
  </code></pre>
  
  <p>How can I get this timer to fire correctly?</p>