ScheduledExecutorService 不能进行任务调度

来源:互联网 发布:镇江学美工设计 编辑:程序博客网 时间:2024/05/02 02:48
环境:java version "1.7.0_67"


private static final long INITIAL_DELAY = 1000L;
private static final long DELAY = 500L;


private ScheduledExecutorService scheduledFullExecutorService = Executors.newSingleThreadScheduledExecutor();


@PostConstruct
public void init() {
    scheduledFullExecutorService.scheduleWithFixedDelay(new Runnable() {
        @Override
        public void run() {
            function();
    }, INITIAL_DELAY, DELAY, TimeUnit.MILLISECONDS);
}


如果function()出现未捕获的异常,导致scheduledFullExecutorService不能进行任务调度


测试方法:
function() {
    if (true) {
        throw new RuntimeException("test");
    }
    // code
    ...
}
0 0
原创粉丝点击