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.

  • 相关阅读:
    软工实践个人总结
    第02组 Beta版本演示
    第02组 Beta冲刺(5/5)
    第02组 Beta冲刺(4/5)
    第02组 Beta冲刺(3/5)
    第02组 Beta冲刺(2/5)
    第02组 Beta冲刺(1/5)
    第02组 Alpha事后诸葛亮
    第02组 Alpha冲刺(6/6)
    第02组 Alpha冲刺(5/6)
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6158011.html
Copyright © 2011-2022 走看看