Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwenchi committed Jul 1, 2024
1 parent e83a97a commit ee99afa
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -1514,7 +1515,20 @@ public void rollback() {
}

public void shutdownExecutorService() {
if (!updateStatisticsExecutor.isShutdown()) {
// Disable new tasks from being submitted
updateStatisticsExecutor.shutdown();
try {
// Wait a while for existing tasks to terminate
if (!updateStatisticsExecutor.awaitTermination(60, TimeUnit.SECONDS)) {
// Cancel currently executing tasks
updateStatisticsExecutor.shutdownNow();
// Wait a while for tasks to respond to being cancelled
if (!updateStatisticsExecutor.awaitTermination(60, TimeUnit.SECONDS)) {
LOG.warn("Pool did not terminate");
}
}
} catch (InterruptedException e) {
// (Re-)Cancel if current thread also interrupted
updateStatisticsExecutor.shutdownNow();
}
}
Expand Down

0 comments on commit ee99afa

Please sign in to comment.