我看到调度程序甚至在删除它之后返回相同的作业(scheduler.getCurrentlyExecutingJobs())(scheduler.deleteJob(jobExCntxt.getJobDetail()。getName(),jobExCntxt.getJobDetail()。getGroup()))。我做对了吗?我想永远删除该作业和关联的线程。那可能吗?
try {
List<JobExecutionContext> jobExCntxts = scheduler.getCurrentlyExecutingJobs();
if(jobExCntxts != null){
for(JobExecutionContext jobExCntxt: jobExCntxts){
if(jobExCntxt != null){
Date triggerTime = DateUtils.addMinutes(jobExCntxt.getTrigger().getPreviousFireTime(), 1);
if(triggerTime.before(Calendar.getInstance().getTime())){
System.out.println("Deleting a long living job !");
System.out.println("Delete return = " + scheduler.deleteJob(jobExCntxt.getJobDetail().getName(),
jobExCntxt.getJobDetail().getGroup()));
}
}
}
}
} catch (SchedulerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
答案 0 :(得分:0)
你尝试过中断()工作吗? deleteJob()仅从作业存储中删除作业。