-2

Is there any way to add a timer in java program? I mean the code will execute only after the time complete and then repeat it-self..

1 Answers1

1

You can use the java.util.Timer and TimerTask classes.

In a nutshell you create a subclass of the TimerTask class, implement the code you want to schedule by overriding the run method, then use a Timer instance to schedule it.

erosb
  • 2,943
  • 15
  • 22