From 93d8a38f9fd0746b9ce6ac7541bf2b8b48f7c63c Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 18 十二月 2024 13:11:24 +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