gpt4 book ai didi

tomcat - 嵌入式 Tomcat : how to configure the number of request threads

转载 作者:行者123 更新时间:2023-11-28 22:03:13 26 4
gpt4 key购买 nike

Embedded Tomcat中,如何配置请求线程数

我似乎无法让它工作。我尝试了所有这些但都没有成功:

  • tomcat.getConnector().setProperty("maxThreads", "20");
  • tomcat.getConnector().setAttribute("maxThreads", "20");
  • tomcat.getConnector().setAttribute("最大线程", 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上的介绍)

关于tomcat - 嵌入式 Tomcat : how to configure the number of request threads,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16920221/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com