打印日志

This commit is contained in:
Guoqs
2024-09-10 11:42:06 +08:00
parent 6a2bfe75c5
commit 409307db85
2 changed files with 48 additions and 3 deletions

View File

@@ -2,6 +2,8 @@ package com.jsowell.framework.config;
import com.jsowell.common.util.Threads;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -17,6 +19,8 @@ import java.util.concurrent.ThreadPoolExecutor;
**/
@Configuration
public class ThreadPoolConfig {
Logger log = LoggerFactory.getLogger(ThreadPoolConfig.class);
// 核心线程池大小
private final int corePoolSize = 50;
@@ -41,6 +45,7 @@ public class ThreadPoolConfig {
executor.setKeepAliveSeconds(keepAliveSeconds);
// 线程池对拒绝任务(无线程可用)的处理策略
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
log.info("threadPoolTaskExecutor创建成功");
return executor;
}
@@ -49,6 +54,7 @@ public class ThreadPoolConfig {
*/
@Bean(name = "scheduledExecutorService")
protected ScheduledExecutorService scheduledExecutorService() {
log.info("scheduledExecutorService创建成功");
return new ScheduledThreadPoolExecutor(corePoolSize,
new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build(),
new ThreadPoolExecutor.CallerRunsPolicy()) {