ScheduledExecutorService 应用

  private volatile ScheduledFuture<?> pfConfigDataRefreshTask;

  private final ScheduledExecutorService refreshPFConfigDataService = Executors
            .newSingleThreadScheduledExecutor();

 

 

    private void schedulePFConfigDataRefreshTask(int delay) {
        log.warn("start to schedule pfConfigDataRefreshTask!");
        if (pfConfigDataRefreshTask == null || pfConfigDataRefreshTask.isDone()) {
            pfConfigDataRefreshTask = refreshPFConfigDataService.schedule(
                    new SetUpPFConfigRunnable(), delay, TimeUnit.SECONDS);
        }
        log.warn("schedule pfConfigDataRefreshTask finished!");
    }

你可能感兴趣的:(executorService)