diff --git a/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java b/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java index 9fc7928..368e87f 100644 --- a/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java +++ b/src/main/java/org/warp/commonutils/concurrency/executor/BoundedExecutorService.java @@ -58,6 +58,7 @@ public class BoundedExecutorService { long keepAliveTime, TimeUnit unit, @Nullable BiConsumer queueSizeStatus) { + if (corePoolSize <= 0) throw new IllegalArgumentException("Core pool size must be >=1 if the executor service is bounded"); return create(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, Executors.defaultThreadFactory(), queueSizeStatus); } @@ -69,6 +70,7 @@ public class BoundedExecutorService { TimeUnit unit, ThreadFactory threadFactory, @Nullable BiConsumer queueSizeStatus) { + if (corePoolSize <= 0) throw new IllegalArgumentException("Core pool size must be >=1 if the executor service is bounded"); return createCustom(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, threadFactory, Duration.ofDays(100000), queueSizeStatus, new LinkedBlockingQueue<>(MAX_BLOCKING_QUEUE_SIZE)); } @@ -81,6 +83,7 @@ public class BoundedExecutorService { ThreadFactory threadFactory, @Nullable BiConsumer queueSizeStatus, BlockingQueue queue) { + if (corePoolSize <= 0) throw new IllegalArgumentException("Core pool size must be >=1 if the executor service is bounded"); return createCustom(maxQueueSize, corePoolSize, maxPoolSize, keepAliveTime, unit, threadFactory, Duration.ofDays(100000), queueSizeStatus, queue); }