/** * Trigger the timer immediately. * <p> * Exposed for testing. */ public void trigger() { synchronized (timerTask) { if (this.complete) { LOG.warn("Timer already completed, not triggering."); return; } LOG.debug("Triggering timer immediately!"); this.timer.cancel(); this.timerTask.run(); } } }
@Signature public void run() { getWrappedObject().run(); }
task.run(); taskCompletedNormally = true; } finally {
/** * 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(); } }
/** * 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, long) */ public void schedule(TimerTask task, long delay) { if (timerThreadRunning) { timer.schedule(task, delay); } else { task.run(); } }
/** * 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, long) */ public void schedule(TimerTask task, Date firstTime, long period) { if (timerThreadRunning) { timer.schedule(task, firstTime, period); } else { task.run(); } }
/** * 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, long, long) */ public void schedule(TimerTask task, long delay, long period) { if (timerThreadRunning) { timer.schedule(task, delay, period); } else { task.run(); } }
/** * 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(); } }
/** * 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, long, long) */ public void scheduleAtFixedRate(TimerTask task, long delay, long period) { if (timerThreadRunning) { timer.scheduleAtFixedRate(task, delay, period); } else { task.run(); } }
@VisibleForTesting static void runAllTasks() { for (TimerTask task : SCHEDULED_TASKS) { task.run(); } }
public void startCountDown(){ timer= new Timer(); TimerTask timerTask =new TimerTask() { @Override public void run() { handler.sendEmptyMessage(0); } }; timer.schedule(timerTask,0,1000); timerTask.run(); } public void finishCount(){
@Override public void run(Object environment) { if (task instanceof ITimerTask) ((ITimerTask)task).run(environment); else task.run(); }
/** * * Executes the timer's task whether the timer is scheduled or not. The * implementation first tries to cancel the timer, then executes the * task directly (via TimerTask.run()). * */ public final void executeNow() { cancel(); _task.run(); }
void runAllScheduledTasks() { for (TimerTask task : scheduledRates.keySet()) { task.run(); } }
@Override public void doit() throws Exception { if (task instanceof ITimerTask && ((ITimerTask)task).isCanceled()) { cancel(); return; } task.run(); }
@Override public void handleEvent(Event event) { btnRefresh.setData("Pressing", "1"); task.run(); btnRefresh.setData("Pressing", null); } });
protected void doit() throws Exception { if (task == null) { cancel(); return; } TimerTask taskTask = task.get(); if (taskTask == null || MTimerTask.getStatus(taskTask) == MTimerTask.CANCELLED ) { cancel(); return; } taskTask.run(); }
@Override public void run() { if (isCanceled()) { cancel(); return; } try { task.run(); } catch (Throwable thrown) { handleException(thrown); } }
public void testRun() throws Exception { final ProxyGrantingTicketStorageTestImpl storage = new ProxyGrantingTicketStorageTestImpl(); new Cas20ProxyReceivingTicketValidationFilter().setProxyGrantingTicketStorage(storage); final TimerTask timerTask = new CleanUpTimerTask(storage); timerTask.run(); assertTrue(storage.cleanUpWasCalled()); }