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 d6d93c76f047573b3e7ea91409fb85e093666812..f1008096ee90b506c322fd1667c6b60faefd545c 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) {