官方文档地址:Number of threads


    Apache Http Async 客户端在默认情况下启动一个调度程序线程,以及连接管理器使用的多个工作线程,与本地检测到的处理器数量相同(取决于Runtime.getRuntime().availableProcessors()返回的内容)。线程数修改方式如下:

    1. RestClientBuilder builder = RestClient.builder(
    2. new HttpHost("localhost", 9200))
    3. .setHttpClientConfigCallback(new HttpClientConfigCallback() {
    4. @Override
    5. public HttpAsyncClientBuilder customizeHttpClient(
    6. HttpAsyncClientBuilder httpClientBuilder) {
    7. return httpClientBuilder.setDefaultIOReactorConfig(
    8. IOReactorConfig.custom()
    9. .setIoThreadCount(1)
    10. .build());
    11. }
    12. });