博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
线程池
阅读量:3711 次
发布时间:2019-05-21

本文共 1191 字,大约阅读时间需要 3 分钟。

ThreadPoolConfig

package com.newland.iot.config;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.core.task.TaskExecutor;import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;@Configurationpublic class ThreadPoolConfig {    @Value("${spring.executor.core.pool.size:500}")    private Integer corePoolSize;    @Value("${spring.executor.max.pool.size:0x7fffffff}")    private Integer maxPoolSize;    @Value("${spring.executor.queue.capacity:0x7fffffff}")    private Integer queueCapacity;    @Bean    public TaskExecutor taskExecutor() {        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();        taskExecutor.setCorePoolSize(corePoolSize);        taskExecutor.setMaxPoolSize(maxPoolSize);        taskExecutor.setQueueCapacity(queueCapacity);        taskExecutor.setWaitForTasksToCompleteOnShutdown(true);        return taskExecutor;    }}

使用

@Componentpublic class TestTaskExecutor {    @Autowired    private TaskExecutor taskExecutor;    taskExecutor.execute(() -> System.out.println("taskExecutor..."));}

 

转载地址:http://vpsjn.baihongyu.com/

你可能感兴趣的文章
快速入门kafka④ 常用命令及API使用
查看>>
快速入门Scala① 介绍及开发环境安装
查看>>
快速入门Scala② 快速入门基本语法
查看>>
快速入门Scala③ scala循环操作
查看>>
SparkCore快速入门及介绍
查看>>
Spark快速入门API① Transformation转换算子
查看>>
SparkSQL介绍及快速入门
查看>>
SparkSQL快速入门DataFrame与DataSet
查看>>
SparkSQL查询风格SQL与DSL介绍及使用
查看>>
SparkSQL使用IDEA快速入门DataFrame与DataSet
查看>>
SparkSQL实现wordCount与资源转换
查看>>
SparkSQL 自定义函数UDF与UDAF
查看>>
SparkSQL介绍并实现开窗函数
查看>>
快速入门Shell脚本(1)——Shell脚本的介绍
查看>>
快速入门Shell脚本(2)——系统变量与自定义变量
查看>>
快速入门Shell脚本(3)——条件判断语句与循环
查看>>
快速入门Shell脚本(4)——常用的函数操作
查看>>
快速入门Shell脚本(5)——Shell的这些工具你都知道了吗?
查看>>
快速入门Shell脚本(6)——学会这些大厂面试题你还害怕面试官问你?(建议收藏)
查看>>
快速入门Flink(1)——Flink介绍与架构体系
查看>>