diff --git a/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceThreadPool.java b/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceThreadPool.java index 464fe7e1..ac2e20d5 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceThreadPool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceThreadPool.java @@ -1,5 +1,6 @@ package org.cloud.sonic.agent.bridge.android; +import jakarta.annotation.PreDestroy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -16,7 +17,15 @@ public class AndroidDeviceThreadPool { public static ExecutorService cachedThreadPool; @Bean - public void androidThreadPoolInit() { + public ExecutorService androidThreadPoolInit() { cachedThreadPool = Executors.newCachedThreadPool(); + return cachedThreadPool; + } + + @PreDestroy + public void shutdownThreadPool() { + if (cachedThreadPool != null) { + cachedThreadPool.shutdown(); + } } } \ No newline at end of file diff --git a/src/main/java/org/cloud/sonic/agent/bridge/ios/IOSDeviceThreadPool.java b/src/main/java/org/cloud/sonic/agent/bridge/ios/IOSDeviceThreadPool.java index 68dab5a9..3475c859 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/ios/IOSDeviceThreadPool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/ios/IOSDeviceThreadPool.java @@ -1,11 +1,11 @@ package org.cloud.sonic.agent.bridge.ios; +import jakarta.annotation.PreDestroy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - /** * @author ZhouYiXun * @des 所有iOS相关线程都放这个线程池 @@ -16,7 +16,15 @@ public class IOSDeviceThreadPool { public static ExecutorService cachedThreadPool; @Bean - public void iOSThreadPoolInit() { + public ExecutorService iOSThreadPoolInit() { cachedThreadPool = Executors.newCachedThreadPool(); + return cachedThreadPool; + } + + @PreDestroy + public void shutdownThreadPool() { + if (cachedThreadPool != null) { + cachedThreadPool.shutdown(); + } } } \ No newline at end of file diff --git a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java index 07251a7e..1576abd1 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java @@ -37,7 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Bean; +import jakarta.annotation.PostConstruct; import org.springframework.context.annotation.DependsOn; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.core.Ordered; @@ -83,7 +83,7 @@ public class SibTool implements ApplicationListener { private RestTemplate restTemplateBean; private static Map webViewMap = new HashMap<>(); - @Bean + @PostConstruct public void setEnv() { bundleId = getBundleId; xcodeProjectPath = getXcodeProjectPath;