【问题标题】:How to add thread pool in Jetty 9.2.24 HttpClient?如何在 Jetty 9.2.24 HttpClient 中添加线程池?
【发布时间】:2018-01-16 14:19:39
【问题描述】:

在 Jetty 9 中,HttpClient 的 setThreadPool 方法已被删除。任何人都可以建议在 Jetty 9 中使用另一种方法吗?

这就是我在以前版本的 Jetty 的HttpClient 中的做法:

QueuedThreadPool queuedThreadpool= new QueuedThreadPool(5);
queuedThreadpool.setMinThreads(2);
queuedThreadpool.setName("HttpClient");

httpClient.setThreadPool(queuedThreadpool); // <<<<<<
httpClient.start();

【问题讨论】:

    标签: java jetty jetty-9 jetty-8


    【解决方案1】:

    现在您需要使用setExecutor(executor)。 QueuedThreadPool 实现了 Executor 接口。

    QueuedThreadPool queuedThreadpool= new QueuedThreadPool(5);
    queuedThreadpool.setMinThreads(2);
    queuedThreadpool.setName("HttpClient");
    
    httpClient.setExecutor(queuedThreadpool);
    httpClient.start();
    

    【讨论】:

    • 感谢您的回复。
    猜你喜欢
    • 2013-04-11
    • 2021-06-01
    • 2021-10-31
    • 1970-01-01
    • 2013-09-03
    • 2015-02-07
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多