如何使用嵌入式Jetty v 9.1.0设置端口和线程池 [英] How do you set both port and thread pool using embedded jetty, v 9.1.0
本文介绍了如何使用嵌入式Jetty v 9.1.0设置端口和线程池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Jetty 9.1.0(嵌入式),并且想同时设置端口和ThreadPool。我看到了每个的构造函数,但看不到如何使用其中的一个,然后再以任何方式设置另一个。
I'm using jetty 9.1.0, embedded, and would like to set both port and ThreadPool. I see a constructor for each, but don't see how to use one of those, and then any way to set the other.
这样做
Server server = new Server(9090);
或
Server server = new Server(new QueuedThreadPool(100, 10));
但服务器上没有setPort或setThreadPool。
but there's no setPort or setThreadPool on Server.
推荐答案
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
Server server = new Server(threadPool);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
http.setPort(81);
server.addConnector(http);
这篇关于如何使用嵌入式Jetty v 9.1.0设置端口和线程池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文