From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 23 Oct 2018 23:14:38 -0400 Subject: [PATCH] Improve Server Thread Pool and Thread Priorities Use a simple executor since Fork join is a much more complex pool type and we are not using its capabilities. Set thread priorities so main thread has above normal priority over server threads Allow usage of a single thread executor by not using ForkJoin so single core CPU's. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index aea9e169f9a11378c176c0cc3ee5a0d59e6a4c38..354109e5f7a8e1b0895e12002951a4bd3bf7dd0c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -175,6 +175,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant { - ForkJoinWorkerThread forkjoinworkerthread = new ForkJoinWorkerThread(forkjoinpool) { + object = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue(), target -> new ServerWorkerThread(target, s, priorityModifier)); + } + /* protected void onTermination(Throwable throwable) { if (throwable != null) { SystemUtils.LOGGER.warn("{} died", this.getName(), throwable); @@ -103,6 +106,7 @@ public class SystemUtils { return forkjoinworkerthread; }, SystemUtils::a, true); } + }*/ // Paper end return (ExecutorService) object; } @@ -151,6 +155,7 @@ public class SystemUtils { }); } + public static void onThreadError(Thread thread, Throwable throwable) { a(thread, throwable); } // Paper - OBFHELPER private static void a(Thread thread, Throwable throwable) { c(throwable); if (throwable instanceof CompletionException) {