I use ScheduledExecutorService
to do a timer task:
scheduledExcutorService.schedule(timerTask, 5000, TimeUnit.MILLISECONDS)
The TimerTask is a Runnable object:
public class TimerTask implements Runnable {
public void run() {
//do something
}
}
Usually, I want to do something in 5 minutes, but in some conditions, I need to delay this task.(cancel it and put it to the ScheduledExecutorService
again with another 5 minutes delay)
But how can I achieve this?