07-22-2009 01:12 PM - edited 07-22-2009 01:19 PM
private final static int HEARTBEAT_TIME_MILLISECONDS = 10000;
...
this._heartBeatTimer.scheduleAtFixedRate(
new TimerTask(){
public void run(){
SystemLog.log(SystemLog.DEBUG, "LnpClient: Injecting heartbeat job");
IClientJob job = new HeartBeatJob();
_jobQueue.enqueue(job);
}
},
HEARTBEAT_TIME_MILLISECONDS,
HEARTBEAT_TIME_MILLISECONDS);
We assume that the 'next execution' time is stored as a calculated datetime and that if on checking this to be passed, the scheduler fires the timer, and then simply adds the timer increment to the date stored. Resulting in the timer immediately firing again until it has caught up.
If our assumtion is correct, sheduled timer tasks are potentially dangerous (in our case firing so frequently the device locked).
Solved! Go to Solution.
07-22-2009 01:26 PM
07-22-2009 02:11 PM
Many thanks CMY.
Just reviewed the documentation again and it does clearly call this behaviour out - so note to self, double check. In our case, as we are only after a regular, periodic 'heartbeat', and given that small variations do not matter, sleep will probably suffice.
Thanks again.