You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查询Spring Boot 2.0.8RELEASE及Undertow 1.4.2的默认线程参数

查询Spring Boot 2.0.8.RELEASE + Undertow 1.4.2的默认线程池与队列大小

一、通过代码直接获取默认值

在Spring Boot应用中添加以下代码,运行后即可打印出默认参数:

import io.undertow.UndertowOptions;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class YourApplication {

    public static void main(String[] args) {
        // 打印Undertow默认IO线程池大小
        System.out.println("默认IO线程池大小: " + UndertowOptions.WORKER_IO_THREADS.getDefaultValue());
        // 打印默认任务核心线程数
        System.out.println("默认任务核心线程数: " + UndertowOptions.WORKER_TASK_CORE_THREADS.getDefaultValue());
        // 打印默认任务最大线程数
        System.out.println("默认任务最大线程数: " + UndertowOptions.WORKER_TASK_MAX_THREADS.getDefaultValue());
        // 任务线程池默认使用无界队列,无固定大小限制
        System.out.println("默认任务线程队列: 无界LinkedBlockingQueue(无固定容量限制)");
        
        SpringApplication.run(YourApplication.class, args);
    }
}

二、查看源码确认默认值

Undertow 1.4.2层面

  • IO线程池大小:默认值为CPU核心数 × 2,定义在io.undertow.UndertowOptions类的WORKER_IO_THREADS参数中
  • 任务线程池参数:核心线程数与最大线程数默认均为CPU核心数 × 8,对应WORKER_TASK_CORE_THREADS和WORKER_TASK_MAX_THREADS参数
  • 线程队列:任务线程池默认使用LinkedBlockingQueue,属于无界队列,没有固定容量限制

Spring Boot 2.0.8层面

Spring Boot的UndertowWebServerFactoryCustomizer自动配置类不会修改Undertow的上述默认值,若未在application.properties/application.yml中自定义配置,将直接沿用Undertow的原生默认参数。

内容的提问来源于stack exchange,提问作者Chaithra Shenoy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 18:45:22