From 49bf62a3fcb72e82167f25c8a2b3d87431c9416b Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 17 十二月 2024 10:46:39 +0800 Subject: [PATCH] # --- zy-acs-fake/src/main/java/com/zy/acs/fake/FakeProcessor.java | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/zy-acs-fake/src/main/java/com/zy/acs/fake/FakeProcessor.java b/zy-acs-fake/src/main/java/com/zy/acs/fake/FakeProcessor.java index 22cc7ba..5587996 100644 --- a/zy-acs-fake/src/main/java/com/zy/acs/fake/FakeProcessor.java +++ b/zy-acs-fake/src/main/java/com/zy/acs/fake/FakeProcessor.java @@ -21,6 +21,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; /** * Created by vincent on 11/9/2024 @@ -69,6 +70,7 @@ if (null == this.executorService) { int count = agvList.size(); this.executorService = Executors.newFixedThreadPool(count); + log.info("Initialized ExecutorService with {} threads.", count); } this.responseTheRequest(); @@ -119,4 +121,23 @@ } } + private void shutdownExecutorService() { + if (this.executorService != null && !executorService.isShutdown()) { + log.info("Shutting down ExecutorService."); + executorService.shutdown(); + try { + if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) { + log.warn("ExecutorService did not terminate in the specified time."); + executorService.shutdownNow(); + } + } catch (InterruptedException e) { + log.error("Interrupted while waiting for ExecutorService to terminate.", e); + executorService.shutdownNow(); + Thread.currentThread().interrupt(); + } finally { + this.executorService = null; + } + } + } + } -- Gitblit v1.9.1