zoukankan      html  css  js  c++  java
  • 【并发编程】ThreadPoolExecutor参数详解

    ThreadPoolExecutor executor = new ThreadPoolExecutor(
    int corePoolSize,
    int maximumPoolSize,
    long keepAliveTime,
    TimeUnit unit,
    BlockingQueue<Runnable> workQueue);


    Core pool size
    The lower limit of threads that are contained in the thread pool. Actually, the thread
    pool starts with zero threads, but once the core pool size is reached, the number of
    threads does not fall below this lower limit. If a task is added to the queue when the
    number of worker threads in the pool is lower than the core pool size, a new thread
    will be created even if there are idle threads waiting for tasks. Once the number of
    worker threads is equal to or higher than the core pool size, new worker threads
    are only created if the queue is full—i.e., queuing gets precedence over thread cre‐
    ation.

    Maximum pool size
    The maximum number of threads that can be executed concurrently. Tasks that are
    added to the queue when the maximum pool size is reached will wait in the queue
    until there is an idle thread available to process the task.

    Maximum idle time (keep-alive time)
    Idle threads are kept alive in the thread pool to be prepared for incoming tasks to
    process, but if the alive time is set, the system can reclaim noncore pool threads.
    The alive time is configured in TimeUnits , the unit the time is measured in.

    Task queue type
    An implementation of BlockingQueue that holds
    tasks added by the consumer until they can be processed by a worker thread. De‐
    pending on the requirements, the queuing policy can vary.

  • 相关阅读:
    8626 原子量计数
    17229 Lry,你除了2还是2
    11153 kill boss
    1143 多少个Fibonacci数
    8614 素数__
    We Chall-Training: Stegano I-Writeup
    We Chall-Training: Get Sourced-Writeup
    We Chall-Prime Factory-Writeup
    CTF入门指南
    pwnable.kr-collision -Writeup
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6158011.html
Copyright © 2011-2022 走看看