Skip to content

Instantly share code, notes, and snippets.

@vmarcinko
Created May 22, 2019 06:47
Show Gist options
  • Save vmarcinko/35ae2af5bb3f51cea7c2efee74881899 to your computer and use it in GitHub Desktop.
Save vmarcinko/35ae2af5bb3f51cea7c2efee74881899 to your computer and use it in GitHub Desktop.
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
// ...
private void startProcessingTask() {
logger.info("Starting queue processing task with delay of {} secs", this.pollingPeriodInSecs);
Runnable command = this::processQueuedItems;
this.processingTask = this.scheduledExecutorService.scheduleWithFixedDelay(command, pollingPeriodInSecs, pollingPeriodInSecs, TimeUnit.SECONDS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment