List of usage examples for java.util.concurrent ScheduledThreadPoolExecutor setMaximumPoolSize
public void setMaximumPoolSize(int maximumPoolSize)
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 www . j av a2 s . com*/ return executor; }
From source file:eu.stratosphere.sopremo.server.SopremoServer.java
private ScheduledThreadPoolExecutor createExecutor() { final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); executor.setMaximumPoolSize(1); return executor; }
From source file:org.mule.config.pool.DefaultThreadPoolFactory.java
protected ScheduledThreadPoolExecutor internalCreateScheduledPool(ThreadingProfile tp) { ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor( Math.min(tp.getMaxThreadsIdle(), tp.getMaxThreadsActive())); scheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); scheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(true); scheduledThreadPoolExecutor.setKeepAliveTime(tp.getThreadTTL(), TimeUnit.MILLISECONDS); scheduledThreadPoolExecutor.setCorePoolSize(tp.getMaxThreadsIdle()); scheduledThreadPoolExecutor.setMaximumPoolSize(tp.getMaxThreadsActive()); return scheduledThreadPoolExecutor; }