From 4f8eab6610413317b16fe6127c60ff994616e85a Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 23 十二月 2024 13:58:45 +0800 Subject: [PATCH] # --- zy-acs-fake/src/main/java/com/zy/acs/fake/FakeProcessor.java | 22 ++++++++++++++++++++++ 1 files changed, 22 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..3f606a0 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(); @@ -81,6 +83,7 @@ if (!AGV_PROCESSING_MAP.get(agv.getId())) { List<Action> actionList = actionService.queryLatestGroup(agv.getId(), ActionStsType.ISSUED); if (!Cools.isEmpty(actionList)) { + AGV_PROCESSING_MAP.put(agv.getId(), true); executorService.submit(new AgvSimulatorTask( agv , redis @@ -119,4 +122,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