如何更改嵌入式Jetty 9中的線程池大小?我們是否需要任何特定的組件?更改Jetty 9中的線程池大小
23
A
回答
24
從docs:
服務器實例提供一個線程池實例,它是默認 執行人服務等Jetty服務器組件使用。線程池的主要配置 是最大和最小大小,並且在etc/jetty.xml中設置了 。
<Configure id="server" class="org.eclipse.jetty.server.Server">
<Set name="threadPool">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">1000</Set>
</New>
</Set>
</Configure>
或者
QueuedThreadPool threadPool = new QueuedThreadPool(100, 10);
Server server = new Server(threadPool);
19
如上所述,並且在上面的Java代碼示例糾正,線程池現在作爲在碼頭9(及後續版本)構造器參數。
修正XML例如:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Configure the Server Thread Pool. -->
<!-- -->
<!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool -->
<!-- for all configuration that may be set here. -->
<!-- =========================================================== -->
<Get name="ThreadPool">
<Set name="minThreads" type="int">10</Set>
<Set name="maxThreads" type="int">200</Set>
<Set name="idleTimeout" type="int">60000</Set>
<Set name="detailedDump">false</Set>
</Get>
...
相關問題
- 1. 更改JVM的線程池大小
- 2. kibana:更改線程池隊列大小
- 3. Java線程池大小(Executors)
- 4. 優化線程池大小
- 5. 最大併發線程數小於最大線程池大小
- 6. MULE中的默認線程池大小
- 7. android中的最佳線程池大小
- 8. 一(大)的線程池每個應用的組分(更小)的線程池
- 9. Reslet Netty配置 - 線程池大小
- 10. 在Scrapy中設置線程池大小
- 11. 蟒蛇線程池的大小
- 12. 動態調整大小的線程池
- 13. 如何選擇線程池大小?
- 14. 線程池不調整大小
- 15. 線程池最大線程
- 16. Jetty線程池和sun.HttpServer會話
- 17. Java線程池大小和availableProcessors()
- 18. 池大小爲1的Java線程池1
- 19. Jetty 9 WebSocket服務器會話上的最大郵件大小
- 20. Mongo連接池(更改連接池的大小)
- 21. 更改線程上的Delphi線程大小
- 22. 池中的最大線程數
- 23. 線程池中的線程
- 24. 阿卡均衡池中有可變大小的線程池執行人
- 25. 線程池的大小應該達到最大性能?
- 26. 在運行時更改Passenger應用程序池大小
- 27. 固定大小的UI佈局窗格在IE中更改大小9
- 28. 爲什麼tomcat的默認線程池大小如此之大?
- 29. 帶OpenMP的線程池:開銷和更改線程數
- 30. 當池大小小於線程數時,避免ConnectionTimeoutError
您的代碼示例不適用於碼頭9.04的工作,因爲在服務器級不setThreadPool方法。此外,我需要這樣的偏好嵌入式碼頭服務器,我已經更新了一個問題。 –
ThreadPool可以傳入服務器實例的構造函數中,或者只需調用server.getThreadPool()並在調用之前調整.start() –
在Jetty-9中,許多方法簽名已更改爲服務器。現在,它不再是getter和setter,而是更多的構造函數。此外,修復了代碼示例。 – rocketboy