@Test void testNegativeMaxSize() { assertIllegalArgument(() -> ThreadPool.create("test", 10, -1, 10, 20, 2, TimeUnit.MINUTES, 1000, "test-thread", true, new ThreadPool.RejectionHandler() ), "maxPoolSize < 0"); }
@SuppressWarnings("checkstyle:ParameterNumber") static ThreadPool create(String name, int corePoolSize, int maxPoolSize, int growthThreshold, int growthRate, long keepAliveTime, TimeUnit keepAliveTimeUnits, int workQueueCapacity, String threadNamePrefix, boolean useDaemonThreads, RejectionHandler rejectionHandler) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name is null or empty"); } else if (corePoolSize < 0) { throw new IllegalArgumentException("corePoolSize < 0"); } else if (maxPoolSize < 0) { throw new IllegalArgumentException("maxPoolSize < 0"); } else if (maxPoolSize < corePoolSize) { throw new IllegalArgumentException("maxPoolSize < corePoolSize"); } else if (growthThreshold < 0) { throw new IllegalArgumentException("growthThreshold < 0"); } else if (growthRate < 0) { throw new IllegalArgumentException("growthRate < 0"); } else if (growthRate > MAX_GROWTH_RATE) { throw new IllegalArgumentException("growthRate > 100"); } else if (keepAliveTime < 1) { throw new IllegalArgumentException("keepAliveTime < 1"); } else if (workQueueCapacity < 1) { throw new IllegalArgumentException("workQueueCapacity < 1"); } else if (threadNamePrefix == null || threadNamePrefix.isEmpty()) { throw new IllegalArgumentException("threadNamePrefix is null or empty"); } else if (rejectionHandler == null) { throw new IllegalArgumentException("rejectionPolicy is null"); } final WorkQueue queue = createQueue(workQueueCapacity, corePoolSize, maxPoolSize, growthThreshold, growthRate); final ThreadFactory threadFactory = new GroupedThreadFactory(name, threadNamePrefix, useDaemonThreads); return new ThreadPool(name, corePoolSize, maxPoolSize, growthThreshold, growthRate, keepAliveTime, keepAliveTimeUnits, threadFactory, queue, rejectionHandler); }
ThreadPool extends ThreadPoolExecutor { @SuppressWarnings("checkstyle:ParameterNumber") static ThreadPool create(String name, int corePoolSize, int maxPoolSize, int growthThreshold, int growthRate, long keepAliveTime, TimeUnit keepAliveTimeUnits, int workQueueCapacity, String threadNamePrefix, boolean useDaemonThreads, RejectionHandler rejectionHandler) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name is null or empty"); } else if (corePoolSize < 0) { throw new IllegalArgumentException("corePoolSize < 0"); } else if (maxPoolSize < 0) { throw new IllegalArgumentException("maxPoolSize < 0"); } else if (maxPoolSize < corePoolSize) { throw new IllegalArgumentException("maxPoolSize < corePoolSize"); } else if (growthThreshold < 0) { throw new IllegalArgumentException("growthThreshold < 0"); } else if (growthRate < 0) { throw new IllegalArgumentException("growthRate < 0"); } else if (growthRate > MAX_GROWTH_RATE) { throw new IllegalArgumentException("growthRate > 100"); } else if (keepAliveTime < 1) { throw new IllegalArgumentException("keepAliveTime < 1"); } else if (workQueueCapacity < 1) { throw new IllegalArgumentException("workQueueCapacity < 1"); } else if (threadNamePrefix == null || threadNamePrefix.isEmpty()) { throw new IllegalArgumentException("threadNamePrefix is null or empty"); } else if (rejectionHandler == null) { throw new IllegalArgumentException("rejectionPolicy is null"); } final WorkQueue queue = createQueue(workQueueCapacity, corePoolSize, maxPoolSize, growthThreshold, growthRate); final ThreadFactory threadFactory = new GroupedThreadFactory(name, threadNamePrefix, useDaemonThreads); return new ThreadPool(name, corePoolSize, maxPoolSize, growthThreshold, growthRate, keepAliveTime, keepAliveTimeUnits, threadFactory, queue, rejectionHandler); } }
ThreadPool extends ThreadPoolExecutor { @SuppressWarnings("checkstyle:ParameterNumber") static ThreadPool create(String name, int corePoolSize, int maxPoolSize, int growthThreshold, int growthRate, long keepAliveTime, TimeUnit keepAliveTimeUnits, int workQueueCapacity, String threadNamePrefix, boolean useDaemonThreads, RejectionHandler rejectionHandler) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name is null or empty"); } else if (corePoolSize < 0) { throw new IllegalArgumentException("corePoolSize < 0"); } else if (maxPoolSize < 0) { throw new IllegalArgumentException("maxPoolSize < 0"); } else if (maxPoolSize < corePoolSize) { throw new IllegalArgumentException("maxPoolSize < corePoolSize"); } else if (growthThreshold < 0) { throw new IllegalArgumentException("growthThreshold < 0"); } else if (growthRate < 0) { throw new IllegalArgumentException("growthRate < 0"); } else if (growthRate > MAX_GROWTH_RATE) { throw new IllegalArgumentException("growthRate > 100"); } else if (keepAliveTime < 1) { throw new IllegalArgumentException("keepAliveTime < 1"); } else if (workQueueCapacity < 1) { throw new IllegalArgumentException("workQueueCapacity < 1"); } else if (threadNamePrefix == null || threadNamePrefix.isEmpty()) { throw new IllegalArgumentException("threadNamePrefix is null or empty"); } else if (rejectionHandler == null) { throw new IllegalArgumentException("rejectionPolicy is null"); } final WorkQueue queue = createQueue(workQueueCapacity, corePoolSize, maxPoolSize, growthThreshold, growthRate); final ThreadFactory threadFactory = new GroupedThreadFactory(name, threadNamePrefix, useDaemonThreads); return new ThreadPool(name, corePoolSize, maxPoolSize, growthThreshold, growthRate, keepAliveTime, keepAliveTimeUnits, threadFactory, queue, rejectionHandler); } 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 { @SuppressWarnings("checkstyle:ParameterNumber") static ThreadPool create(String name, int corePoolSize, int maxPoolSize, int growthThreshold, int growthRate, long keepAliveTime, TimeUnit keepAliveTimeUnits, int workQueueCapacity, String threadNamePrefix, boolean useDaemonThreads, RejectionHandler rejectionHandler) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name is null or empty"); } else if (corePoolSize < 0) { throw new IllegalArgumentException("corePoolSize < 0"); } else if (maxPoolSize < 0) { throw new IllegalArgumentException("maxPoolSize < 0"); } else if (maxPoolSize < corePoolSize) { throw new IllegalArgumentException("maxPoolSize < corePoolSize"); } else if (growthThreshold < 0) { throw new IllegalArgumentException("growthThreshold < 0"); } else if (growthRate < 0) { throw new IllegalArgumentException("growthRate < 0"); } else if (growthRate > MAX_GROWTH_RATE) { throw new IllegalArgumentException("growthRate > 100"); } else if (keepAliveTime < 1) { throw new IllegalArgumentException("keepAliveTime < 1"); } else if (workQueueCapacity < 1) { throw new IllegalArgumentException("workQueueCapacity < 1"); } else if (threadNamePrefix == null || threadNamePrefix.isEmpty()) { throw new IllegalArgumentException("threadNamePrefix is null or empty"); } else if (rejectionHandler == null) { throw new IllegalArgumentException("rejectionPolicy is null"); } final WorkQueue queue = createQueue(workQueueCapacity, corePoolSize, maxPoolSize, growthThreshold, growthRate); final ThreadFactory threadFactory = new GroupedThreadFactory(name, threadNamePrefix, useDaemonThreads); return new ThreadPool(name, corePoolSize, maxPoolSize, growthThreshold, growthRate, keepAliveTime, keepAliveTimeUnits, threadFactory, queue, rejectionHandler); } 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 { @SuppressWarnings("checkstyle:ParameterNumber") static ThreadPool create(String name, int corePoolSize, int maxPoolSize, int growthThreshold, int growthRate, long keepAliveTime, TimeUnit keepAliveTimeUnits, int workQueueCapacity, String threadNamePrefix, boolean useDaemonThreads, RejectionHandler rejectionHandler) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name is null or empty"); } else if (corePoolSize < 0) { throw new IllegalArgumentException("corePoolSize < 0"); } else if (maxPoolSize < 0) { throw new IllegalArgumentException("maxPoolSize < 0"); } else if (maxPoolSize < corePoolSize) { throw new IllegalArgumentException("maxPoolSize < corePoolSize"); } else if (growthThreshold < 0) { throw new IllegalArgumentException("growthThreshold < 0"); } else if (growthRate < 0) { throw new IllegalArgumentException("growthRate < 0"); } else if (growthRate > MAX_GROWTH_RATE) { throw new IllegalArgumentException("growthRate > 100"); } else if (keepAliveTime < 1) { throw new IllegalArgumentException("keepAliveTime < 1"); } else if (workQueueCapacity < 1) { throw new IllegalArgumentException("workQueueCapacity < 1"); } else if (threadNamePrefix == null || threadNamePrefix.isEmpty()) { throw new IllegalArgumentException("threadNamePrefix is null or empty"); } else if (rejectionHandler == null) { throw new IllegalArgumentException("rejectionPolicy is null"); } final WorkQueue queue = createQueue(workQueueCapacity, corePoolSize, maxPoolSize, growthThreshold, growthRate); final ThreadFactory threadFactory = new GroupedThreadFactory(name, threadNamePrefix, useDaemonThreads); return new ThreadPool(name, corePoolSize, maxPoolSize, growthThreshold, growthRate, keepAliveTime, keepAliveTimeUnits, threadFactory, queue, rejectionHandler); } 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();  }