From f2aea5ef3a6826d04c2d5c71bf0ada31d480c91b Mon Sep 17 00:00:00 2001 From: Qingtian Wang Date: Thu, 16 May 2024 00:42:37 -0500 Subject: [PATCH] + rename --- src/main/java/conseq4j/execute/ConseqExecutor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/conseq4j/execute/ConseqExecutor.java b/src/main/java/conseq4j/execute/ConseqExecutor.java index 6868569..3b23e5c 100644 --- a/src/main/java/conseq4j/execute/ConseqExecutor.java +++ b/src/main/java/conseq4j/execute/ConseqExecutor.java @@ -46,11 +46,11 @@ @ThreadSafe @ToString public final class ConseqExecutor implements SequentialExecutor, Terminable, AutoCloseable { - - public static final int ADMIN_WORKER_PARALLELISM = + private static final int DEFAULT_WORKER_CONCURRENCY = Runtime.getRuntime().availableProcessors(); + private static final int ADMIN_WORKER_CONCURRENCY = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); + private final ExecutorService adminService = Executors.newWorkStealingPool(ADMIN_WORKER_CONCURRENCY); private final Map> activeSequentialTasks = new ConcurrentHashMap<>(); - private final ExecutorService adminService = Executors.newWorkStealingPool(ADMIN_WORKER_PARALLELISM); /** * The worker thread pool facilitates the overall async execution, independent of the submitted tasks. Any thread * from the pool can be used to execute any task, regardless of sequence keys. The pool capacity decides the overall @@ -64,7 +64,7 @@ private ConseqExecutor(ExecutorService workerExecutorService) { /** @return conseq executor with default concurrency */ public static @Nonnull ConseqExecutor instance() { - return instance(Runtime.getRuntime().availableProcessors()); + return instance(DEFAULT_WORKER_CONCURRENCY); } /**