Refine search
/** * Cancel any running timer for the connection lost detection * @since 1.3.4 */ private void cancelConnectionLostTimer() { if( connectionLostTimer != null ) { connectionLostTimer.cancel(); connectionLostTimer = null; } if( connectionLostTimerTask != null ) { connectionLostTimerTask.cancel(); connectionLostTimerTask = null; } }
if (task.isScheduled()) { throw new IllegalStateException("TimerTask is scheduled already");
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); } }
reportTimerTask.run(); final Timer timer = new Timer(true); timer.schedule(reportTimerTask, reportToConsoleInterval, reportToConsoleInterval); m_terminalLogger.info("This test will shut down after {} ms", duration); timer.schedule(shutdownTimerTask, duration); reportTimerTask.cancel(); shutdownTimerTask.cancel(); reportTimerTask.run();
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); } } } }
final TimerTask tt = new TimerTask() { @Override public void run() { if (count < 1000) { //increment rectangles y position //now repaint container so we can see changes in co-ordinates (unless you have a timer which repaints for you too) count++; } else {//counter is at 1000 stop the timer cancel(); } } }; new Timer().scheduleAtFixedRate(tt, 0, 10);//start in 0milis and call run every 10 milis
/** * If the runtime environment restricts thread creation, the task is run * inline for only one time. No further repeated execution happens for the * task * * @see java.util.Timer#schedule(java.util.TimerTask, java.util.Date) */ public void schedule(TimerTask task, Date time) { if (timerThreadRunning) { timer.schedule(task, time); } else { task.run(); } }
public void shutdown() { if (cleanup != null) { cleanup.cancel(); cleanup = null; } }
private void stopGetGuidTimer() { if (this.mGetGuidTimer instanceof Timer) { this.mGetGuidTimer.cancel(); this.mGetGuidTimer.purge(); this.mGetGuidTimer = null; XLLog.i(TAG, "stopGetGuidTimer"); } if (this.mGetGuidTimerTask instanceof TimerTask) { this.mGetGuidTimerTask.cancel(); this.mGetGuidTimerTask = null; } }
public synchronized void setOptimizeDuration(long optimizeDuration) { if (_optimizeDuration != optimizeDuration) { _currentOptimizationTimerTask.cancel(); _optimizeTimer.purge(); _currentOptimizationTimerTask = new OptimizeTimerTask(); _optimizeTimer.scheduleAtFixedRate(_currentOptimizationTimerTask, _dateToStartOptimize, optimizeDuration); _optimizeDuration = optimizeDuration; } }
/** * If the runtime environment restricts thread creation, the task is run * inline for only one time. No further repeated execution happens for the * task * * @see java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long) */ public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { if (timerThreadRunning) { timer.scheduleAtFixedRate(task, firstTime, period); } else { task.run(); } }
@Signature public void run() { getWrappedObject().run(); }
task.setScheduledTime(task.when); task.run(); taskCompletedNormally = true; } finally {