ScheduledExecutorService.scheduleAtFixedRate tends to run enormous
amounts of runnables that would have been scheduled during a machine is
in sleep, after the machines wakes up from sleep, retroactively.
This is not good and can be avoided by using scheduleWithFixedDelay
which is usually good enough regarding the delay between executions.
gitlab #531
Change-Id: I4ac3b11f1f9236d411debb352fce610c33410659
}
public void register(INode node) {
}
public void register(INode node) {
- // We use ths size of this map to determine whether updates are needed, this is done in AWT thread
+ // We use the size of this map to determine whether updates are needed, this is done in AWT thread
synchronized(requesters) {
if(requesters.size() == 0) {
if(state.compareAndSet(false, true)) {
synchronized(requesters) {
if(requesters.size() == 0) {
if(state.compareAndSet(false, true)) {
- ThreadUtils.getNonBlockingWorkExecutor().scheduleAtFixedRate(this, 0, 500, TimeUnit.MILLISECONDS);
+ ThreadUtils.getNonBlockingWorkExecutor().scheduleWithFixedDelay(this, 0, 500, TimeUnit.MILLISECONDS);
}
}
ICanvasContext context = DiagramNodeUtil.getPossibleCanvasContext((G2DNode)node);
}
}
ICanvasContext context = DiagramNodeUtil.getPossibleCanvasContext((G2DNode)node);
// long delay = 1000 / 25; this sounds quite frequent
long delay = 1000 / 10;
lastTrigger = System.currentTimeMillis();
// long delay = 1000 / 25; this sounds quite frequent
long delay = 1000 / 10;
lastTrigger = System.currentTimeMillis();
- timer.scheduleAtFixedRate(task, delay, delay, TimeUnit.MILLISECONDS);
+ timer.scheduleWithFixedDelay(task, delay, delay, TimeUnit.MILLISECONDS);
}
@HintListener(Class = Hints.class, Field = "KEY_CANVAS_BOUNDS")
}
@HintListener(Class = Hints.class, Field = "KEY_CANVAS_BOUNDS")
return;
long interval = getInterval();
return;
long interval = getInterval();
- future = ThreadUtils.getNonBlockingWorkExecutor().scheduleAtFixedRate(onTimer, DEFAULT_INTERVAL, interval, TimeUnit.MILLISECONDS);
+ future = ThreadUtils.getNonBlockingWorkExecutor().scheduleWithFixedDelay(onTimer, DEFAULT_INTERVAL, interval, TimeUnit.MILLISECONDS);
}
private void cancelTimer() {
}
private void cancelTimer() {