Jetty 9.2.24 HttpClient 如何添加线程池?

How to add thread pool in Jetty 9.2.24 HttpClient?

在 Jetty 9 中,HttpClientsetThreadPool 方法已被删除。任何人都可以建议在 Jetty 9 中执行此操作的替代方法吗?

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

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

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

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

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

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