• 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;
        }
    }
  • 相关阅读:
    html5 to jsp
    java通过springMail发送邮件
    solr配置-Solrconfig.xml
    solr配置-Schema.xml
    solr连接数据库导入数据
    log4j 1.2 配置总结
    1-12 ARP协议
    1-11 ICMP协议
    1-10 网际层
    1-9 TCP/IP参考模型
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/7387807.html
Copyright © 2020-2023  润新知