From ad809600b63df3ec1e57b9b9692c8ca2b99af166 Mon Sep 17 00:00:00 2001 From: "Blue (Lukas Rieger)" Date: Fri, 2 Apr 2021 13:18:33 +0200 Subject: [PATCH] Improve thread-pool-settings for the WebServer --- .../de/bluecolored/bluemap/core/webserver/WebServer.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/WebServer.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/WebServer.java index dc0e0520..6940eae5 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/WebServer.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/WebServer.java @@ -31,10 +31,7 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; public class WebServer extends Thread { @@ -68,8 +65,7 @@ public WebServer(InetAddress bindAddress, int port, int maxConnections, HttpRequ public synchronized void start() { close(); - connectionThreads = new ThreadPoolExecutor(maxConnections, maxConnections, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); - connectionThreads.allowCoreThreadTimeOut(true); + connectionThreads = new ThreadPoolExecutor(Math.min(maxConnections, 8), maxConnections, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); try { server = new ServerSocket(port, maxConnections, bindAddress);