0
我想使用相同的设置(每10秒)(javax.ejb.Timer)再次启动时间表我已经停止了时间表后:再次启动时间表: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) {
}
}
这是我的功能停止的时间表:
galleryScheduleExecutionService.cancelTimer("mySchedule");
这里的时间表:
@Lock(LockType.READ)
@AccessTimeout(value = 20, unit = TimeUnit.MINUTES)
@Schedule(second = "*/10", minute = "*", hour = "*", persistent = false, info = "mySchedule")
public void schedule()
throws StorageAttachmentNotFoundException, IOException,
DuplicateStorageAttachmentException,
CannotDuplicateStorageAttachmentException,
ApplicationInfoNotFoundException, PrintStorageNotFoundException,
InterruptedException {
try {
// start schedule
galleryScheduleService.doStartSchedule();
} catch (Exception e) {
e.printStackTrace();
}
}
如何开始的时间表再次使用相同的设置(每10秒...)?
这种超时回调方法的原因是什么? – internet
它是createTimer方法的目标。实际上重启一个自动定时器是不可能的('@ Schedule'),所以你可以做的最好的是创建一个等效的编程定时器,它使用相同的回调方法。 –