@Test void testGrowth() throws Exception { int coreSize = 2; int maxSize = 8; int growthThreshold = 10; int growthRate = 100; int expectedActiveThreads; CountDownLatch awaitRunning; pool = newPool(coreSize, maxSize, growthThreshold, growthRate); awaitRunning = addTasks(coreSize); expectedActiveThreads = coreSize; waitUntilActiveThreadsIs(expectedActiveThreads, awaitRunning); assertThat(pool.getPoolSize(), is(coreSize)); assertThat(pool.getQueueSize(), is(0)); addTasks(growthThreshold + 1); assertThat(pool.getPoolSize(), is(coreSize)); assertThat(pool.getQueueSize(), is(growthThreshold + 1)); for (int i = coreSize; i < maxSize; i++) { addTasks(1); expectedActiveThreads++; waitUntilActiveThreadsIs(expectedActiveThreads); } assertThat(pool.getPoolSize(), is(maxSize)); assertThat(pool.getQueueSize(), is(growthThreshold + 1)); while (!tasks.isEmpty()) { tasks.remove(0).finish(); } waitUntil(() -> pool.getQueueSize() == 0); waitUntil(() -> pool.getPoolSize() == coreSize); awaitRunning = addTasks(coreSize); waitUntilActiveThreadsIs(coreSize, awaitRunning); addTasks(growthThreshold + 1); assertThat(pool.getPoolSize(), is(coreSize)); assertThat(pool.getQueueSize(), is(growthThreshold + 1)); addTasks(1); waitUntilActiveThreadsIs(coreSize + 1); }
public int getQueueSize() { return queue.size(); }
ThreadPool extends ThreadPoolExecutor { public int getQueueSize() { return queue.size(); } }
ThreadPool extends ThreadPoolExecutor { public int getQueueSize() { return queue.size(); } private  ThreadPool(String name,
                       int corePoolSize,
                       int maximumPoolSize,
                       int growthThreshold,
                       int growthRate,
                       long keepAliveTime,
                       TimeUnit keepAliveTimeUnit,
                       ThreadFactory threadFactory,
                       WorkQueue queue,
                       RejectionHandler rejectionHandler); }
ThreadPool extends ThreadPoolExecutor { public int getQueueSize() { return queue.size(); } private  ThreadPool(String name,
                       int corePoolSize,
                       int maximumPoolSize,
                       int growthThreshold,
                       int growthRate,
                       long keepAliveTime,
                       TimeUnit keepAliveTimeUnit,
                       ThreadFactory threadFactory,
                       WorkQueue queue,
                       RejectionHandler rejectionHandler); static Optional<ThreadPool> asThreadPool(ExecutorService executor); String getName(); int getQueueCapacity(); float getAverageQueueSize(); int getPeakQueueSize(); int getCompletedTasks(); int getFailedTasks(); int getTotalTasks(); int getActiveThreads(); float getAverageActiveThreads(); int getRejectionCount(); boolean isFixedSize(); @Override WorkQueue getQueue(); int getQueueSize(); @Override void setRejectedExecutionHandler(RejectedExecutionHandler handler); @Override RejectionHandler getRejectedExecutionHandler(); @Override void setMaximumPoolSize(int maximumPoolSize); @Override String toString(); @Override void shutdown(); }
ThreadPool extends ThreadPoolExecutor { public int getQueueSize() { return queue.size(); } private  ThreadPool(String name,
                       int corePoolSize,
                       int maximumPoolSize,
                       int growthThreshold,
                       int growthRate,
                       long keepAliveTime,
                       TimeUnit keepAliveTimeUnit,
                       ThreadFactory threadFactory,
                       WorkQueue queue,
                       RejectionHandler rejectionHandler); static Optional<ThreadPool> asThreadPool(ExecutorService executor); String getName(); int getQueueCapacity(); float getAverageQueueSize(); int getPeakQueueSize(); int getCompletedTasks(); int getFailedTasks(); int getTotalTasks(); int getActiveThreads(); float getAverageActiveThreads(); int getRejectionCount(); boolean isFixedSize(); @Override WorkQueue getQueue(); int getQueueSize(); @Override void setRejectedExecutionHandler(RejectedExecutionHandler handler); @Override RejectionHandler getRejectedExecutionHandler(); @Override void setMaximumPoolSize(int maximumPoolSize); @Override String toString(); @Override void shutdown();  }