timertask - Java Timer : Cancel all the missed exections -
i using
scheduleatfixedrate(timertask task, date firsttime, long period)
in program. if start time passed, tasks missed between start time , current time executed. documentation says:
as consequence of above, if scheduled first time in past, "missed" executions scheduled immediate "catch up" execution.
is there way stop these "catch up" executions?
i think best can use schedule
call instead:
schedule(timertask task, long delay, long period)
and beforehand calculate delay required first task start. if desired start time has passed use delay of 0. this:
long delay = starttime.gettime() - system.currenttimemillis(); delay = delay < 0 ? 0 : delay;
Comments
Post a Comment