List of usage examples for java.util.concurrent ScheduledThreadPoolExecutor setRejectedExecutionHandler
public void setRejectedExecutionHandler(RejectedExecutionHandler handler)
From source file:io.bitsquare.common.util.Utilities.java
public static ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor(String name, int corePoolSize, int maximumPoolSize, long keepAliveTimeInSec) { final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name).setDaemon(true) .setPriority(Thread.MIN_PRIORITY).build(); ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(corePoolSize, threadFactory); executor.setKeepAliveTime(keepAliveTimeInSec, TimeUnit.SECONDS); executor.allowCoreThreadTimeOut(true); executor.setMaximumPoolSize(maximumPoolSize); executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); executor.setRejectedExecutionHandler((r, e) -> { log.debug("RejectedExecutionHandler called"); });/*from w w w.j a v a 2s. c om*/ return executor; }