/** * @return the core size of this thread pool. */ @ManagedAttribute(id="thread-pool-core-pool-size") @Description("The initial/minimum number of threads managed by this thread pool.") public int getCorePoolSize() { return threadPool.getConfig().getCorePoolSize(); }
/** * @return the core size of this thread pool. */ @ManagedAttribute(id="thread-pool-core-pool-size") @Description("The initial/minimum number of threads managed by this thread pool.") public int getCorePoolSize() { return threadPool.getConfig().getCorePoolSize(); }
protected final void setImpl(ThreadPoolConfig cfg) { if (cfg == null) { throw new IllegalArgumentException("config is null"); } cfg = cfg.copy(); if (cfg.getMemoryManager() == null) { cfg.setMemoryManager(MemoryManager.DEFAULT_MEMORY_MANAGER); } final Queue<Runnable> queue = cfg.getQueue(); if ((queue == null || queue instanceof BlockingQueue) && (cfg.getCorePoolSize() < 0 || cfg.getCorePoolSize() == cfg.getMaxPoolSize())) { this.pool = cfg.getQueueLimit() < 0 ? new FixedThreadPool(cfg) : new QueueLimitedThreadPool(cfg); } else { this.pool = new SyncThreadPool(cfg); } this.config = cfg; }
protected final void setImpl(ThreadPoolConfig cfg) { if (cfg == null) { throw new IllegalArgumentException("config is null"); } cfg = cfg.copy(); if (cfg.getMemoryManager() == null) { cfg.setMemoryManager(MemoryManager.DEFAULT_MEMORY_MANAGER); } final Queue<Runnable> queue = cfg.getQueue(); if ((queue == null || queue instanceof BlockingQueue) && (cfg.getCorePoolSize() < 0 || cfg.getCorePoolSize() == cfg.getMaxPoolSize())) { this.pool = cfg.getQueueLimit() < 0 ? new FixedThreadPool(cfg) : new QueueLimitedThreadPool(cfg); } else { this.pool = new SyncThreadPool(cfg); } this.config = cfg; }
protected final void setImpl(ThreadPoolConfig cfg) { if (cfg == null) { throw new IllegalArgumentException("config is null"); } cfg = cfg.copy(); if (cfg.getMemoryManager() == null) { cfg.setMemoryManager(MemoryManager.DEFAULT_MEMORY_MANAGER); } final Queue<Runnable> queue = cfg.getQueue(); if ((queue == null || queue instanceof BlockingQueue) && (cfg.getCorePoolSize() < 0 || cfg.getCorePoolSize() == cfg.getMaxPoolSize())) { this.pool = cfg.getQueueLimit() < 0 ? new FixedThreadPool(cfg) : new QueueLimitedThreadPool(cfg); } else { this.pool = new SyncThreadPool(cfg); } this.config = cfg; }
protected final void setImpl(ThreadPoolConfig cfg) { if (cfg == null) { throw new IllegalArgumentException("config is null"); } cfg = cfg.copy(); if (cfg.getMemoryManager() == null) { cfg.setMemoryManager(MemoryManager.DEFAULT_MEMORY_MANAGER); } final Queue<Runnable> queue = cfg.getQueue(); if ((queue == null || queue instanceof BlockingQueue) && (cfg.getCorePoolSize() < 0 || cfg.getCorePoolSize() == cfg.getMaxPoolSize())) { this.pool = cfg.getQueueLimit() < 0 ? new FixedThreadPool(cfg) : new QueueLimitedThreadPool(cfg); } else { this.pool = new SyncThreadPool(cfg); } this.config = cfg; }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
/** * */ public SyncThreadPool(ThreadPoolConfig config) { super(config); if (config.getKeepAliveTime(TimeUnit.MILLISECONDS) < 0) { throw new IllegalArgumentException("keepAliveTime < 0"); } workQueue = config.getQueue() != null ? config.getQueue() : config.setQueue(new LinkedList<Runnable>()).getQueue(); this.maxQueuedTasks = config.getQueueLimit(); final int corePoolSize = config.getCorePoolSize(); while (currentPoolSize < corePoolSize) { startWorker(new SyncThreadWorker(true)); } ProbeNotifier.notifyThreadPoolStarted(this); }
@Reset public void reset() { if (threadPoolConfig != null) { maxThreadsCount.setCount(threadPoolConfig.getMaxPoolSize()); coreThreadsCount.setCount(threadPoolConfig.getCorePoolSize()); currentThreadCount.setCount(0); currentThreadsBusy.setCount(0); } totalExecutedTasksCount.setCount(0); } }
@Test public void testWorkerThreadPoolConfiguration() throws Exception { LOGGER.log(Level.INFO, "Running: testWorkerThreadPoolConfiguration ({0})", transport.getName()); ThreadPoolConfig config = ThreadPoolConfig.defaultConfig(); config.setCorePoolSize(1); config.setMaxPoolSize(1); config.setPoolName("custom"); transport.setWorkerThreadPoolConfig(config); transport.setIOStrategy(WorkerThreadIOStrategy.getInstance()); ThreadPoolConfig underTest = transport.getWorkerThreadPoolConfig(); assertEquals(1, underTest.getCorePoolSize()); assertEquals(1, underTest.getMaxPoolSize()); assertEquals("custom", underTest.getPoolName()); }