zoukankan      html  css  js  c++  java
  • 线程池七大参数解析

    先展示一下jdk8中ThreadPoolExecutor构造方法的源码

    public ThreadPoolExecutor(int corePoolSize,
    int maximumPoolSize,
    long keepAliveTime,
    TimeUnit unit,
    BlockingQueue<Runnable> workQueue,
    ThreadFactory threadFactory,
    RejectedExecutionHandler handler) {
    if (corePoolSize < 0 ||
    maximumPoolSize <= 0 ||
    maximumPoolSize < corePoolSize ||
    keepAliveTime < 0)
    throw new IllegalArgumentException();
    if (workQueue == null || threadFactory == null || handler == null)
    throw new NullPointerException();
    this.acc = System.getSecurityManager() == null ?
    null :
    AccessController.getContext();
    this.corePoolSize = corePoolSize;
    this.maximumPoolSize = maximumPoolSize;
    this.workQueue = workQueue;
    this.keepAliveTime = unit.toNanos(keepAliveTime);
    this.threadFactory = threadFactory;
    this.handler = handler;
    }
    corePoolSize    //核心线程数量,会一直存在,除非allowCoreThreadTimeOut设置为true
    maximumPoolSize  //线程池允许的最大线程池数量
    keepAliveTime   //线程数量超过corePoolSize,空闲线程的最大超时时间
    unit        //超时时间的单位
    workQueue     //工作队列,保存未执行的Runnable 任务
    threadFactory   //创建线程的工厂类
    handler      //当线程已满,工作队列也满了的时候,会被调用。被用来实现各种拒绝策略。
  • 相关阅读:
    oracle 3大范式 理解
    RobHess的SIFT代码解析之RANSAC
    RobHess的SIFT代码解析步骤四
    RobHess的SIFT代码解析步骤三
    RobHess的SIFT代码解析步骤二
    《我的十年图像生涯》—王郑耀(西安交通大学)
    图像卷积
    多尺度分析方法及表达方式
    图像处理中双线性插值
    程序面试题——C实现
  • 原文地址:https://www.cnblogs.com/chuzijing/p/14445866.html
Copyright © 2011-2022 走看看