Skip to content

Commit

Permalink
Not enough to p.shutdown, one has to p.awaitTermination
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Apr 28, 2023
1 parent ae3050e commit f71557d
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
}

Expand Down

0 comments on commit f71557d

Please sign in to comment.