【问题标题】:thread pool task executor ,,,what is the maximum pool size, core pool size can be defined in java线程池任务执行器,,,最大池大小是多少,核心池大小可以在java中定义
【发布时间】:2021-10-03 03:25:20
【问题描述】:

我们可以在 java spring boot 框架中分配的最大 corepoolsize、maxpoolsize、queuecapacity 是多少。我在公司工作,需要处理更多线程请求。我必须提高线程性能。现有的具有默认值。

public Executor asyncExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(corePoolSize);
    executor.setMaxPoolSize(maxPoolSize);
    executor.setQueueCapacity(queueCapacity);
    return executor;
}

【问题讨论】:

  • 有一篇关于数字的好文章:engineering.zalando.com/posts/2019/04/…
  • 增加线程甚至可能减慢您的应用程序。创建/添加更多线程不是解决方案。根据您的处理器等,它甚至可能使事情变得更糟。此外,如果您需要增加请求吞吐量,使用 ThreadPoolTaskExecutor 也无济于事(除非您将其用于异步 servlet API 处理)。

标签: java multithreading spring-boot threadpool executorservice


【解决方案1】:

核心池大小默认配置为1,最大池大小和队列容量为2147483647。

【讨论】:

    猜你喜欢
    • 2022-06-19
    • 2013-01-11
    • 2022-12-29
    • 2016-03-20
    • 2016-09-01
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多