问题
In Embedded Tomcat, how can I configure the number of request threads?
I can't seem to get it to work. I tried all of these without success:
- tomcat.getConnector().setProperty("maxThreads", "20");
- tomcat.getConnector().setAttribute("maxThreads", "20");
- tomcat.getConnector().setAttribute("maxThreads", 20);
回答1:
If you want embedded tomcat to refuse new connections after 20 connections, you should also set acceptCount attribute. So, below code should work and refuse new connections after 20.
tomcat.getConnector().setAttribute("maxThreads", "20");
tomcat.getConnector().setAttribute("acceptCount", "20");
(check the introduction on http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)
来源:https://stackoverflow.com/questions/16920221/embedded-tomcat-how-to-configure-the-number-of-request-threads