在Embedded Tomcat中,如何配置请求线程数?
我似乎无法让它工作。我尝试了所有这些都没有成功:
- tomcat.getConnector().setProperty("maxThreads", "20");
- tomcat.getConnector().setAttribute("maxThreads", "20");
- tomcat.getConnector().setAttribute("maxThreads", 20);
在Embedded Tomcat中,如何配置请求线程数?
我似乎无法让它工作。我尝试了所有这些都没有成功:
如果您希望嵌入式 tomcat 在 20 个连接后拒绝新连接,您还应该设置 acceptCount 属性。因此,下面的代码应该可以工作并在 20 岁之后拒绝新的连接。
tomcat.getConnector().setAttribute("maxThreads", "20");
tomcat.getConnector().setAttribute("acceptCount", "20");
(查看http://tomcat.apache.org/tomcat-7.0-doc/config/http.html上的介绍)