Reputation: 666
I want to execute method to run every five minutes and want to release the resources. Can anybody explain how to schedule a loop so that I can execute loop every five minutes or so.
Thanks,
Upvotes: 2
Views: 1467
Reputation: 3036
You can use TimerTask
, and Timer
to make schedule task, read about these helper-link-1, helper-link-2
Upvotes: 1
Reputation: 172408
You can try like this:
Timer timer = new Timer ();
TimerTask sometask = new TimerTask () {
@Override
public void run () {
// code
}
};
timer.schedule (sometask, 0l, 1000*60*5);
Upvotes: 2