Open showlist opened 3 years ago
任务终止时通过 “interrupt” 执行线程的方式实现, 将会触发 “InterruptedException” 异常。因此如果JobHandler内部catch到了该异常并消化掉的话, 任务终止功能将不可用。
因此, 如果遇到上述任务终止不可用的情况, 需要在JobHandler中应该针对 “InterruptedException” 异常进行特殊处理 (向上抛出) , 正确逻辑如下:
try{ // do something } catch (Exception e) { if (e instanceof InterruptedException) { throw e; } logger.warn("{}", e); }
而且,在JobHandler中开启子线程时,子线程也不可catch处理”InterruptedException”,应该主动向上抛出。
不是说要向上抛出才能停止么?
同样的问题
`@Component public class DemoGlueJobHandler extends IJobHandler {
}` 在调度中心和管理后台能正常停用任务,采用的是GLUE(Java)模式