Reputation: 23
Can someone please help me? I have this java program that needs to perform a task every minute of the computer's clock.
May I know if this is possible, and if yes what is the best way to do this?
Thank you very much!
Upvotes: 1
Views: 243
Reputation: 172468
You may try this:
int delay = 60000; // delay for 1 min.
int period = 5000; // repeat every 5 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
// Task here ...
}
}, delay, period);
Upvotes: 1