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 f9608bf0eb4e3dfc573fe626e7da9fccf69dc783..e08f913403c3cf3e6efec6c6409f046600c9eb7f 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) {