zoukankan      html  css  js  c++  java
  • 自定义线程池配置类

    1、线程池参数
    /**
     * @author houChen
     * @date 2021/12/11 11:05
     * @Description: 线程池参数
     */
    @Component
    @ConfigurationProperties(prefix = "gulimall.thread")
    @Data
    public class ThreadPoolConfigProperties {
    
        private Integer coreSize;
    
        private Integer maxSize;
    
        private Integer keepAliveTime;
    }
    2、自定义线程池配置类
    /**
     * @author houChen
     * @date 2021/12/11 10:35
     * @Description:   自定义线程池配置类
     */
    @Configuration
    public class MyThreadConfig {
    
        @Bean
        public ThreadPoolExecutor threadPoolExecutor(ThreadPoolConfigProperties properties){
    
            ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                    properties.getCoreSize(),
                    properties.getMaxSize(),
                    properties.getKeepAliveTime(),
                    TimeUnit.SECONDS,
                    new LinkedBlockingQueue<>(100000),
                    Executors.defaultThreadFactory(),
                    new ThreadPoolExecutor.AbortPolicy());
    
            return threadPoolExecutor;
        }
    }
  • 相关阅读:
    HTTP客户端
    获取IP地址和域名
    SQL语句、PL/SQL块和SQL*Plus命令之间的区别
    oracle中的游标
    oracle表问题
    精简版web浏览器
    oracle的存储过程
    数据库中的视图
    第一次作业
    折半查找
  • 原文地址:https://www.cnblogs.com/houchen/p/15779442.html
Copyright © 2011-2022 走看看