Skip to content

Commit ad80960

Browse files
committed
Improve thread-pool-settings for the WebServer
1 parent 5a342e1 commit ad80960

File tree

1 file changed

+2
-6
lines changed
  • BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver

1 file changed

+2
-6
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/WebServer.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
import java.net.ServerSocket;
3232
import java.net.Socket;
3333
import java.net.SocketException;
34-
import java.util.concurrent.LinkedBlockingQueue;
35-
import java.util.concurrent.RejectedExecutionException;
36-
import java.util.concurrent.ThreadPoolExecutor;
37-
import java.util.concurrent.TimeUnit;
34+
import java.util.concurrent.*;
3835

3936
public class WebServer extends Thread {
4037

@@ -68,8 +65,7 @@ public WebServer(InetAddress bindAddress, int port, int maxConnections, HttpRequ
6865
public synchronized void start() {
6966
close();
7067

71-
connectionThreads = new ThreadPoolExecutor(maxConnections, maxConnections, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
72-
connectionThreads.allowCoreThreadTimeOut(true);
68+
connectionThreads = new ThreadPoolExecutor(Math.min(maxConnections, 8), maxConnections, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
7369

7470
try {
7571
server = new ServerSocket(port, maxConnections, bindAddress);

0 commit comments

Comments
 (0)