@Async异步方法默认使用Spring创建ThreadPoolTaskExecutor。默认核心线程数:8,最大线程数:Integet.MAX_VALUE,队列使用LinkedBlockingQueue,容量是:Integet.MAX_VALUE,空闲线程保留时间:60s,线程池拒绝策略:AbortPolicy。

可以手动配置相应属性:

#核心线程数
spring.task.execution.pool.core-size=200 #最大线程数
spring
.task.execution.pool.max-size=1000 #空闲线程保留时间
spring
.task.execution.pool.keep-alive=3s #队列容量
spring
.task.execution.pool.queue-capacity=1000 #线程名称前缀
spring
.task.execution.thread-name-prefix=test-thread-

 

配置类是TaskExecutionProperties【org.springframework.boot.autoconfigure.task.TaskExecutionProperties】

【springboot】@Async线程默认配置

【springboot】@Async线程默认配置

【springboot】@Async线程默认配置

 

 

 

 

参考地址

https://www.cnblogs.com/hepengju/p/12715034.html 

Spring Boot教程(21) – 默认线程池 : https://zhuanlan.zhihu.com/p/85855282

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-04-01
  • 2021-07-01
  • 2021-07-14
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-03-15
  • 2021-10-27
  • 2021-04-10
相关资源
相似解决方案