@Test public void testRunNames() throws Throwable { ThreadPool threadPool = new ThreadPool(1, 2); threadPool.execute(new TestTask()); ISOUtil.sleep(20); threadPool.execute(new TestTask()); ISOUtil.sleep(20); Thread[] tl = new Thread[threadPool.activeCount()]; threadPool.enumerate(tl); for (Thread t :tl ) assertThat(t.getName(), new MatchesPattern(Pattern.compile("ThreadPool.PooledThread-\\d+-(running|idle)"))); }
public synchronized void execute(Runnable action) throws Closed { if (!pool.ready()) throw new Closed(); if (++jobs % this.maxPoolSize == 0 || pool.consumerCount() <= 0) supervise(); if (running < maxPoolSize && pool.consumerDeficit() >= 0) { new PooledThread().start(); running++; } available--; pool.enqueue (action); }
ThreadPool extends ThreadGroup implements LogSource, Loggeable, Configurable, ThreadPoolMBean { public synchronized void execute(Runnable action) throws Closed { if (!pool.ready()) throw new Closed(); if (++jobs % this.maxPoolSize == 0 || pool.consumerCount() <= 0) supervise(); if (running < maxPoolSize && pool.consumerDeficit() >= 0) { new PooledThread().start(); running++; } available--; pool.enqueue (action); } }
ThreadPool extends ThreadGroup implements LogSource, Loggeable, Configurable, ThreadPoolMBean { public synchronized void execute(Runnable action) throws Closed { if (!pool.ready()) throw new Closed(); if (++jobs % this.maxPoolSize == 0 || pool.consumerCount() <= 0) supervise(); if (running < maxPoolSize && pool.consumerDeficit() >= 0) { new PooledThread().start(); running++; } available--; pool.enqueue (action); } ThreadPool(int poolSize, int maxPoolSize);  ThreadPool(int poolSize, int maxPoolSize, String name);  ThreadPool(); }
ThreadPool extends ThreadGroup implements LogSource, Loggeable, Configurable, ThreadPoolMBean { public synchronized void execute(Runnable action) throws Closed { if (!pool.ready()) throw new Closed(); if (++jobs % this.maxPoolSize == 0 || pool.consumerCount() <= 0) supervise(); if (running < maxPoolSize && pool.consumerDeficit() >= 0) { new PooledThread().start(); running++; } available--; pool.enqueue (action); } ThreadPool(int poolSize, int maxPoolSize);  ThreadPool(int poolSize, int maxPoolSize, String name);  ThreadPool(); void close(); synchronized void execute(Runnable action); void dump(PrintStream p, String indent); int getJobCount(); int getPoolSize(); int getMaxPoolSize(); int getActiveCount(); int getIdleCount(); synchronized int getAvailableCount(); int getPendingCount(); void supervise(); void setLogger(Logger logger, String realm); String getRealm(); Logger getLogger(); void setConfiguration(Configuration cfg); static ThreadPool getThreadPool(java.lang.String name); }
ThreadPool extends ThreadGroup implements LogSource, Loggeable, Configurable, ThreadPoolMBean { public synchronized void execute(Runnable action) throws Closed { if (!pool.ready()) throw new Closed(); if (++jobs % this.maxPoolSize == 0 || pool.consumerCount() <= 0) supervise(); if (running < maxPoolSize && pool.consumerDeficit() >= 0) { new PooledThread().start(); running++; } available--; pool.enqueue (action); } ThreadPool(int poolSize, int maxPoolSize);  ThreadPool(int poolSize, int maxPoolSize, String name);  ThreadPool(); void close(); synchronized void execute(Runnable action); void dump(PrintStream p, String indent); int getJobCount(); int getPoolSize(); int getMaxPoolSize(); int getActiveCount(); int getIdleCount(); synchronized int getAvailableCount(); int getPendingCount(); void supervise(); void setLogger(Logger logger, String realm); String getRealm(); Logger getLogger(); void setConfiguration(Configuration cfg); static ThreadPool getThreadPool(java.lang.String name); static final int DEFAULT_MAX_THREADS; }