mirror of https://github.com/apache/activemq.git
Synchronize method and remove old deprecated schedule method.
This commit is contained in:
parent
1c97a65b45
commit
106f759571
|
@ -560,7 +560,7 @@ public class Topic extends BaseDestination implements Task {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getExpireMessagesPeriod() > 0) {
|
if (getExpireMessagesPeriod() > 0) {
|
||||||
scheduler.schedualPeriodically(expireMessagesTask, getExpireMessagesPeriod());
|
scheduler.executePeriodically(expireMessagesTask, getExpireMessagesPeriod());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,28 +27,16 @@ import org.apache.activemq.util.ServiceSupport;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class Scheduler extends ServiceSupport {
|
public final class Scheduler extends ServiceSupport {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private final HashMap<Runnable, TimerTask> timerTasks = new HashMap<Runnable, TimerTask>();
|
private final HashMap<Runnable, TimerTask> timerTasks = new HashMap<Runnable, TimerTask>();
|
||||||
|
|
||||||
public Scheduler (String name) {
|
public Scheduler(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executePeriodically(final Runnable task, long period) {
|
public synchronized void executePeriodically(final Runnable task, long period) {
|
||||||
TimerTask timerTask = new SchedulerTimerTask(task);
|
|
||||||
timer.schedule(timerTask, period, period);
|
|
||||||
timerTasks.put(task, timerTask);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* execute on rough schedule based on termination of last execution. There is no
|
|
||||||
* compensation (two runs in quick succession) for delays
|
|
||||||
*
|
|
||||||
* @deprecated use {@link #executePeriodically}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public synchronized void schedualPeriodically(final Runnable task, long period) {
|
|
||||||
TimerTask timerTask = new SchedulerTimerTask(task);
|
TimerTask timerTask = new SchedulerTimerTask(task);
|
||||||
timer.schedule(timerTask, period, period);
|
timer.schedule(timerTask, period, period);
|
||||||
timerTasks.put(task, timerTask);
|
timerTasks.put(task, timerTask);
|
||||||
|
|
Loading…
Reference in New Issue