Refine search
private void raiseNotification() { if (timer != null) { synchronized (timer) { if (timerTask != null) { timerTask.cancel(); timerTask = null; } timerTask = new TimerTask() { @Override public void run() { if (startTime != null) { Long endTime = SystemClock.elapsedRealtime(); Timber.i("TracingWakeLock for tag %s / id %d: has been active for %d ms, timeout = %d ms", tag, id, endTime - startTime, timeout); } else { Timber.i("TracingWakeLock for tag %s / id %d: still active, timeout = %d ms", tag, id, timeout); } } }; timer.schedule(timerTask, 1000, 1000); } } } }
void schedule(final int taskId, final Runnable task, long delay) { TimerTask timerTask = new TimerTask() { @Override public void run() { try { task.run(); } finally { cancelTask(taskId); } } }; synchronized (this) { TimerTask previousTimerTask = tasks.put(taskId, timerTask); if (previousTimerTask != null) { previousTimerTask.cancel(); } if (timer == null) { timer = new Timer("Subscription SmartTimer", true); } timer.schedule(timerTask, delay); } }
/** * Cancels current timer task if any and schedules new one to be executed immediately and then every UPDATE_TIME_VIEW * milliseconds. */ private void engageViewAndLogUpdateTimer() { if ( timer == null ) { timer = new Timer( "SpoonSlave: " + getMeta().getName() ); } if ( timerTask != null ) { timerTask.cancel(); } timerTask = new TimerTask() { public void run() { if ( display != null && !display.isDisposed() ) { display.asyncExec( new Runnable() { public void run() { refreshViewAndLog(); } } ); } } }; timer.schedule( timerTask, 0L, UPDATE_TIME_VIEW ); } }
/** * Set a timer for disposing the backing store after the specified amount of milliseconds of * inactivity. The {@link #createBackingStore} method will be responsible for creating a new * backing store when needed. Note that the backing store disposal can be vetoed if {@link * #canDisposeBackingStore} returns {@code false}. * * @param delay The minimal delay before to close the backing store. This delay is very * approximative. The backing store will not be closed before, but may take as much as twice * that time before to be closed. */ public synchronized void setTimeout(final long delay) { // if we have been disposed, don't do anything if (TIMER == null) return; if (disposer != null) { disposer.cancel(); } disposer = new Disposer(); TIMER.schedule(disposer, delay, delay); }
private void scheduleTask(final RrdNioBackend rrdNioBackend) { final TimerTask task = new SyncTimerTask(rrdNioBackend); if (m_tasks.containsKey(rrdNioBackend)) { m_tasks.get(rrdNioBackend).cancel(); } m_tasks.put(rrdNioBackend, task); m_timer.schedule(task, getSyncPeriod() * 1000L, getSyncPeriod() * 1000L); }
/** * Resets the current progress towards timeout to 0. */ protected synchronized void resetTimeout() { if (timeoutTask != null) timeoutTask.cancel(); if (timeoutMillis == 0 || !timeoutEnabled) return; timeoutTask = new TimerTask() { @Override public void run() { timeoutOccurred(); } }; timeoutTimer.schedule(timeoutTask, timeoutMillis); }
/** * Resets the current progress towards timeout to 0. */ protected synchronized void resetTimeout() { if (timeoutTask != null) timeoutTask.cancel(); if (timeoutMillis == 0 || !timeoutEnabled) return; timeoutTask = new TimerTask() { @Override public void run() { timeoutOccurred(); } }; timeoutTimer.schedule(timeoutTask, timeoutMillis); }
/** * Resets the current progress towards timeout to 0. */ protected synchronized void resetTimeout() { if (timeoutTask != null) timeoutTask.cancel(); if (timeoutMillis == 0 || !timeoutEnabled) return; timeoutTask = new TimerTask() { @Override public void run() { timeoutOccurred(); } }; timeoutTimer.schedule(timeoutTask, timeoutMillis); }
/** * Resets the current progress towards timeout to 0. */ protected synchronized void resetTimeout() { if (timeoutTask != null) timeoutTask.cancel(); if (timeoutMillis == 0 || !timeoutEnabled) return; timeoutTask = new TimerTask() { @Override public void run() { timeoutOccurred(); } }; timeoutTimer.schedule(timeoutTask, timeoutMillis); }