From a208fa59b2a9457bced4dfd3b24f92ce4a73f1f6 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sun, 23 Jun 2024 10:29:14 +0800 Subject: [PATCH] =?UTF-8?q?chore(core):=20=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=89=8D=E7=BC=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../threadpool/ThreadPoolAutoConfiguration.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/continew-starter-core/src/main/java/top/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java b/continew-starter-core/src/main/java/top/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java index 400b70df..1d0c907e 100644 --- a/continew-starter-core/src/main/java/top/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java +++ b/continew-starter-core/src/main/java/top/continew/starter/core/autoconfigure/threadpool/ThreadPoolAutoConfiguration.java @@ -64,6 +64,7 @@ public class ThreadPoolAutoConfiguration { @Bean public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties properties) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setThreadNamePrefix("thread-pool"); // 核心(最小)线程数 executor.setCorePoolSize(ObjectUtil.defaultIfNull(properties.getCorePoolSize(), corePoolSize)); // 最大线程数 @@ -98,7 +99,7 @@ public class ThreadPoolAutoConfiguration { } }; // 应用关闭时,关闭线程池 - SpringApplication.getShutdownHandlers().add(() -> shutdown(executor, properties)); + SpringApplication.getShutdownHandlers().add(() -> this.shutdown(executor, properties)); log.debug("[ContiNew Starter] - Auto Configuration 'ScheduledExecutorService' completed initialization."); return executor; } @@ -107,6 +108,7 @@ public class ThreadPoolAutoConfiguration { * 根据相应的配置设置关闭 ExecutorService * * @see org.springframework.scheduling.concurrent.ExecutorConfigurationSupport#shutdown() + * @since 2.0.0 */ public void shutdown(ExecutorService executor, ThreadPoolProperties properties) { log.debug("[ContiNew Starter] - Shutting down ScheduledExecutorService start."); @@ -129,6 +131,7 @@ public class ThreadPoolAutoConfiguration { * * @param task the task to cancel (typically a {@link RunnableFuture}) * @see RunnableFuture#cancel(boolean) + * @since 2.0.0 */ protected void cancelRemainingTask(Runnable task) { if (task instanceof Future future) { @@ -138,6 +141,8 @@ public class ThreadPoolAutoConfiguration { /** * Wait for the executor to terminate, according to the value of the properties + * + * @since 2.0.0 */ private void awaitTerminationIfNecessary(ExecutorService executor, ThreadPoolProperties properties) { if (properties.getAwaitTerminationMillis() > 0) {