如何在Jetty 9.2.24 HttpClient中添加线程池?

时间:2018-01-16 14:19:40

标签: java jetty jetty-9 jetty-8

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

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

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

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

1 个答案:

答案 0 :(得分:0)

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

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

httpClient.setExecutor(queuedThreadpool);
httpClient.start();