From 34b91074c5ce9d46ca87fd4852a32731d2ee610a Mon Sep 17 00:00:00 2001 From: Evan Chicoine Date: Thu, 17 Apr 2025 18:52:41 -0400 Subject: [PATCH 1/2] ThreadUtils thread count adjusted to limited value to avoid lockups in unix based operating systems. --- .../org/opencds/cqf/tooling/common/ThreadUtils.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java b/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java index 72f78e7d1..ad1c26d2e 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java @@ -16,6 +16,8 @@ public class ThreadUtils { private static List runningExecutors = new ArrayList<>(); + private static final int threadPoolCount = Runtime.getRuntime().availableProcessors() * 2; + /** * Executes a list of tasks concurrently using a thread pool. *

@@ -62,11 +64,15 @@ public static void executeTasks(List> tasks, ExecutorService exec } public static void executeTasks(List> tasks) { - executeTasks(tasks, Executors.newCachedThreadPool()); + ExecutorService executor = Executors.newFixedThreadPool(threadPoolCount); + + executeTasks(tasks, executor); } public static void executeTasks(Queue> callables) { - executeTasks(new ArrayList<>(callables), Executors.newCachedThreadPool()); + ExecutorService executor = Executors.newFixedThreadPool(threadPoolCount); + + executeTasks(new ArrayList<>(callables), executor); } public static void shutdownRunningExecutors() { @@ -77,7 +83,7 @@ public static void shutdownRunningExecutors() { } runningExecutors = new ArrayList<>(); }catch (Exception e){ - //fail silently, shutting down anyways + //fail silently, shutting down anyway } } } From e8f1ac9eff5a34655de78a89c74c6b7bd3e487ad Mon Sep 17 00:00:00 2001 From: Evan Chicoine Date: Mon, 5 May 2025 14:42:09 -0400 Subject: [PATCH 2/2] -Dthreadutils.pool.count=8 now a possible argument --- .../main/java/org/opencds/cqf/tooling/common/ThreadUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java b/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java index ad1c26d2e..56a07190b 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/common/ThreadUtils.java @@ -16,7 +16,7 @@ public class ThreadUtils { private static List runningExecutors = new ArrayList<>(); - private static final int threadPoolCount = Runtime.getRuntime().availableProcessors() * 2; + private static final int threadPoolCount = Integer.getInteger("threadutils.pool.count", Runtime.getRuntime().availableProcessors()); /** * Executes a list of tasks concurrently using a thread pool.