zoukankan      html  css  js  c++  java
  • ThreadFactory 线程池工厂

    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    
    public class ThreadFactory {
        private static ExecutorService threadpool = Executors.newFixedThreadPool(200);
        
        public static ExecutorService getThreadpool() {
            return threadpool;
        }
    }

     固定线程池默认抛弃策略,线程超过数量被抛弃不执行,但是队列默认数量是整形的最大数,一般是超不过队列数量加线程池数量

     spring线程池

    import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
    
    import com.yundaex.common.dao.context.SpringContext;
    
    public class ThreadFactory {
        private static ThreadPoolTaskExecutor threadpool = (ThreadPoolTaskExecutor) SpringContext.getBean("taskExecutor");
        
        public static ThreadPoolTaskExecutor getThreadpool() {
            return threadpool;
        }
    }
  • 相关阅读:
    每日一题
    每日一题
    每日一题
    每日一题
    GitLab 部署
    Golang Web开发之Gin入门
    Golang消息队列之NSQ
    Golang操作Redis
    Golang操作MySQL
    Golang Json数据处理方法
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/7387807.html
Copyright © 2011-2022 走看看