From f71557db78c749e4eba109522ea7a42f796e75ef Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Fri, 28 Apr 2023 14:25:54 +0200 Subject: [PATCH] Not enough to p.shutdown, one has to p.awaitTermination --- .../enso/interpreter/runtime/ThreadExecutors.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/ThreadExecutors.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/ThreadExecutors.java index 0484c80ed8eb..394e4e4aa0e6 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/ThreadExecutors.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/ThreadExecutors.java @@ -5,7 +5,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; final class ThreadExecutors { private final EnsoContext context; @@ -32,6 +34,17 @@ public void shutdown() { while (it.hasNext()) { var p = it.next().getKey(); p.shutdown(); + boolean success; + try { + success = p.awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException ex) { + success = false; + } + if (!success) { + context + .getLogger() + .log(Level.WARNING, "Cannot shutdown {0} thread pool", it.next().getValue()); + } } }