• 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;
        }
    }
  • 相关阅读:
    hdu4291 A Short problem
    UVA
    HDU
    Be Geeks!
    HDU
    hdu6559 The Tower
    胜利大逃亡(续) + Maze
    Stealing Harry Potter's Precious
    hdu5172 GTY's gay friends
    Log Concave Sequences Gym
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/7387807.html
Copyright © 2020-2023  润新知