search

Home  >  Q&A  >  body text

多线程 - java 使用current包固定线程池对象,如何动态伸缩?

PHPzPHPz2785 days ago701

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:07:04

    There seems to be no method... Executors is just a thread pool tool class that uses factory methods. FixThreadPool, CachedThreadPool, etc. are all based on thread pools that handle a certain or special situation, so they do not support setting parameters. They can only Improve performance by monitoring the status of the computer to set different values;
    If you must dynamically scale, it is recommended to inherit the ThreadPoolExecutor class yourself, rewrite the beforeExecute, afterExecute, terminated methods, and use the set methods of coreSize, maxinumSize, and keepalivetime to make dynamic adjustments.

    reply
    0
  • Cancelreply