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'),所以你可以做的最好的是創建一個等效的編程定時器,它使用相同的回調方法。 –