#
luxiaotao1123
2024-12-17 49bf62a3fcb72e82167f25c8a2b3d87431c9416b
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;
            }
        }
    }
}