取消后再次启动/启用定时器

时间:2016-06-15 19:12:10

标签: java timer

我有以下功能来停止我的调度程序:

import javax.ejb.Timer;

// call this remote method with the Timer info that has to be canceled
@AccessTimeout(value = 20, unit = TimeUnit.MINUTES)
public void cancelTimer(String timerInfo) {
    try {
        for (Timer timer : timerService.getTimers()) {
            if (timerInfo.equals(timer.getInfo())) {
                timer.cancel();
            }
        }
    } catch (Exception e) {

    }
}

将调用:

cancelTimer("scheduleImagesFromFolder");

但现在我的问题是: 如何重新启用计划?

我的Timer.class是 javax.ejb.Timer

0 个答案:

没有答案