1

I am building a Swing application in Java. I've read that in order to run a GUI task periodically it is recommended to use a Timer object (from javax.swing package). I am trying to understand what is the difference between using the Timer object vs using the sleep method for the Thread. Don't they both achieve the same?

Meir

Meir
  • 1,691
  • 2
  • 14
  • 15

1 Answers1

3

If you sleep the EDT your entire GUI will hang and become unresponsive until the thread wakes up. This is bad.

Qwerky
  • 18,217
  • 6
  • 44
  • 80