Commit c6980c81 authored by AfirSraftGarrier's avatar AfirSraftGarrier

格式

parent f55efe5a
...@@ -2,11 +2,12 @@ package iot.sixiang.license.config; ...@@ -2,11 +2,12 @@ package iot.sixiang.license.config;
/** /**
* Title: ThreadPoolConfig * Title: ThreadPoolConfig
* Description: TODO * Description:
* *
* @author tianlai3 * @author tianlai3
* @date 2022-07-16 20:05:38 * @date 2022-07-16 20:05:38
*/ */
import lombok.Data; import lombok.Data;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -15,22 +16,23 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; ...@@ -15,22 +16,23 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
@Data @Data
@Configuration @Configuration
@EnableAsync @EnableAsync
public class ThreadPoolConfig { public class ThreadPoolConfig {
private static final int corePoolSize = 1; // 核心线程数(默认线程数) private static final int corePoolSize = 1; // 核心线程数(默认线程数)
private static final int maxPoolSize = 2; // 最大线程数 private static final int maxPoolSize = 2; // 最大线程数
private static final int keepAliveTime = 10; // 允许线程空闲时间(单位:默认为秒) private static final int keepAliveTime = 10; // 允许线程空闲时间(单位:默认为秒)
private static final int queueCapacity = 2; // 缓冲队列数 private static final int queueCapacity = 2; // 缓冲队列数
/** /**
* 默认异步线程池 * 默认异步线程池
*
* @return * @return
*/ */
@Bean("taskExecutor") @Bean("taskExecutor")
public Executor taskExecutor(){ public Executor taskExecutor() {
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
pool.setThreadNamePrefix("threadPoll-"); pool.setThreadNamePrefix("threadPoll-");
pool.setCorePoolSize(corePoolSize); pool.setCorePoolSize(corePoolSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment