[concurrency-interest] Scheduling tasks using TimerTask
mydevgroup at gmail.com
Sat Nov 6 20:39:22 EDT 2010
Thanks very much for the suggestion, it is very informative,
I have tried scheduling the task few seconds before the actual deadline and
rescheduling it again for the target time with the recalculated time in
milli seconds. However, this approach doesn't work with frequent ntp
synchronization. It may be that the initial scheduling might have
accumulated error and the second rescheduling only occurs after the target
time has lapsed
As you suggested, if I reschedule the task recursively, say every 5 minutes
till I reach the target time (considering the target time to be 24hours from
a given time). Would there be any significant performance issue that could
be caused by repeated scheduling of TimerTask?
On 06/11/2010 17:43, "Doug Lea" <dl at cs.oswego.edu> wrote:
> On 11/06/10 09:19, George wrote:
>> I would be very grateful to know if there is any solution in Java to
>> maintain second precision on systems with ntp time synchronization enabled
>> (linux). In other words, If I schedule a task to be executed after 24hours ,
>> it should be executed on the second without any deviation of seconds from
>> the set time.
> If you are on a system with an unreliable system clock that undergoes
> frequent ntp adjustment, you can, instead of requesting a
> delay until a given time 24hrs from now, just ask for delay
> of a few minutes. Then check deadline yourself --
> if you've hit it, trigger action, else recalculate the
> next few minutes interval based on current system time and delay again.
> This is a little messy, but not hard.
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
More information about the Concurrency-interest