在嵌入式Tomcat中,如何配置请求线程数?
我似乎不能使它工作。我尝试了所有这些都没有成功:
- tomcat.getConnector()。setProperty("maxThreads"、"20");
- tomcat.getConnector()。setAttribute("maxThreads"、"20");
- tomcat.getConnector()。setAttribute("maxThreads",20);
如果您希望嵌入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上的介绍)