Don't use the scheduleAtFixedRate method in our scheduler as we
don't really have a need for real time task execution, just use
the fixed delay scheduler so that jobs don't stack up.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1174952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-09-23 18:50:15 +00:00
parent 1453c53105
commit ca90cc7b8c
1 changed files with 8 additions and 8 deletions

View File

@ -21,26 +21,26 @@ import java.util.Timer;
import java.util.TimerTask;
/**
*
*
*/
public final class Scheduler {
public static final Timer CLOCK_DAEMON = new Timer("KahaDB Scheduler", true);
public static final Timer CLOCK_DAEMON = new Timer("KahaDB Scheduler", true);
private static final HashMap<Runnable, TimerTask> TIMER_TASKS = new HashMap<Runnable, TimerTask>();
private Scheduler() {
}
public static synchronized void executePeriodically(final Runnable task, long period) {
TimerTask timerTask = new SchedulerTimerTask(task);
CLOCK_DAEMON.scheduleAtFixedRate(timerTask, period, period);
TimerTask timerTask = new SchedulerTimerTask(task);
CLOCK_DAEMON.schedule(timerTask, period, period);
TIMER_TASKS.put(task, timerTask);
}
public static synchronized void cancel(Runnable task) {
TimerTask ticket = TIMER_TASKS.remove(task);
TimerTask ticket = TIMER_TASKS.remove(task);
if (ticket != null) {
ticket.cancel();
CLOCK_DAEMON.purge();//remove cancelled TimerTasks
@ -48,10 +48,10 @@ public final class Scheduler {
}
public static void executeAfterDelay(final Runnable task, long redeliveryDelay) {
TimerTask timerTask = new SchedulerTimerTask(task);
TimerTask timerTask = new SchedulerTimerTask(task);
CLOCK_DAEMON.schedule(timerTask, redeliveryDelay);
}
public static void shutdown() {
CLOCK_DAEMON.cancel();
}