码迷,mamicode.com
首页 > 编程语言 > 详细

线程池创建

时间:2020-05-30 12:57:37      阅读:46      评论:0      收藏:0      [点我收藏+]

标签:stat   lin   runnable   spec   time   daemon   block   pool   navig   

    static final int poolSize = 50;
    static final long keepAliveTime = 0L;
    static final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("Thread-pool-MlanguageNavigationAspect-%d").setDaemon(true).build();
    static final ExecutorService executorService = new ThreadPoolExecutor(
            poolSize,
            poolSize,
            keepAliveTime,
            TimeUnit.MILLISECONDS,
            //无界队列 LinkedBlockingQueue
            //有界队列 ArrayBlockingQueue PriorityBlockingQueue
            //同步移交 SynchronousQueue
            new LinkedBlockingQueue<Runnable>(),
            threadFactory,
            //AbortPolicy中止策略
            //DiscardPolicy抛弃策略
            //DiscardOldestPolicy抛弃旧任务策略
            //CallerRunsPolicy调用者运行
            new ThreadPoolExecutor.AbortPolicy());

 

线程池创建

标签:stat   lin   runnable   spec   time   daemon   block   pool   navig   

原文地址:https://www.cnblogs.com/wanhua-wu/p/12991668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!