Code example for ScheduledThreadPoolExecutor

Methods: scheduleWithFixedDelay

0
  private static final ScheduledThreadPoolExecutor pool = ConcurrencyUtil.newSingleScheduledThreadExecutor("Flushing thread");
 
  private FlushingDaemon() {} 
 
  public static ScheduledFuture<?> everyFiveSeconds(Runnable r) {
    return pool.scheduleWithFixedDelay(r, 5, 5, TimeUnit.SECONDS);
  } 
} 
Experience pair programming with AI  Get Codota for Java