private void fixTimeLimit() { if (timeLimitFuture != null) timeLimitFuture.cancel(true); if (running && limits.containsKey(TIMER_COUNTER)) { long delay = limits.get(TIMER_COUNTER) * 1000 - time; if (delay > 0) { timeLimitFuture = scheduler.schedule(new TimeLimitTask(), delay, TimeUnit.MILLISECONDS); } } }
private void onStartExecution() { log.debug("Starting canvas {}", getLabel()); setRunning(true); setTime(0); synchronized (datesLock) { startTime = new Date(); endTime = null; } timerFuture = scheduler.scheduleAtFixedRate(new TimeUpdateTask(), 250, 250, TimeUnit.MILLISECONDS); fixTimeLimit(); hasStarted = true; setCompleted(false); }