TimerTaskWrapper taskWrapper = new TimerTaskWrapper(task); wrappedTasks.put(task, taskWrapper); timer.schedule(taskWrapper, firstTime, period);
/** * Cancels the execution of a scheduled task. {@link java.util.TimerTask#cancel()} * * @param task the scheduled task to cancel. */ public void cancelScheduledTask(TimerTask task) { TaskEngine.TimerTaskWrapper taskWrapper = wrappedTasks.remove(task); if (taskWrapper != null) { taskWrapper.cancel(); } }
TimerTaskWrapper taskWrapper = new TimerTaskWrapper(task); wrappedTasks.put(task, taskWrapper); try {
TimerTaskWrapper taskWrapper = new TimerTaskWrapper(task); wrappedTasks.put(task, taskWrapper); try {
TimerTaskWrapper taskWrapper = new TimerTaskWrapper(task); wrappedTasks.put(task, taskWrapper); timer.schedule(taskWrapper, delay, period);
/** * Schedules the specified task for execution after the specified delay. * * @param task task to be scheduled. * @param delay delay in milliseconds before task is to be executed. * @throws IllegalArgumentException if <tt>delay</tt> is negative, or * <tt>delay + System.currentTimeMillis()</tt> is negative. * @throws IllegalStateException if task was already scheduled or * cancelled, or timer was cancelled. */ public void schedule(TimerTask task, long delay) { timer.schedule(new TimerTaskWrapper(task), delay); }
/** * Schedules the specified task for execution at the specified time. If * the time is in the past, the task is scheduled for immediate execution. * * @param task task to be scheduled. * @param time time at which task is to be executed. * @throws IllegalArgumentException if <tt>time.getTime()</tt> is negative. * @throws IllegalStateException if task was already scheduled or * cancelled, timer was cancelled, or timer thread terminated. */ public void schedule(TimerTask task, Date time) { timer.schedule(new TimerTaskWrapper(task), time); }