diff --git a/patches/server/0066-Virtual-Thread-for-async-scheduler.patch b/patches/server/0066-Virtual-Thread-for-async-scheduler.patch index 7d89e5639..500b00f14 100644 --- a/patches/server/0066-Virtual-Thread-for-async-scheduler.patch +++ b/patches/server/0066-Virtual-Thread-for-async-scheduler.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Virtual Thread for async scheduler diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java -index 3c1992e212a6d6f1db4d5b807b38d71913619fc0..fe4f1868a5baebceb9ad0520f059ac8c4a68d397 100644 +index 3c1992e212a6d6f1db4d5b807b38d71913619fc0..e9168902552cc6640db3a432dbd9e695f2e3ec9c 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java -@@ -38,17 +38,30 @@ import java.util.concurrent.TimeUnit; +@@ -38,17 +38,40 @@ import java.util.concurrent.TimeUnit; public class CraftAsyncScheduler extends CraftScheduler { @@ -28,13 +28,23 @@ index 3c1992e212a6d6f1db4d5b807b38d71913619fc0..fe4f1868a5baebceb9ad0520f059ac8c + + // Leaf start - Ability to use Virtual Thread for async scheduler + if (org.dreeam.leaf.config.modules.opt.VT4BukkitScheduler.enabled) { -+ executor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("Craft Scheduler Thread - ", 0).factory()); ++ executor = new ThreadPoolExecutor( ++ 4, Integer.MAX_VALUE, 10L, TimeUnit.SECONDS, new SynchronousQueue<>(), // Use 10s for keepalive time ++ Thread.ofVirtual() ++ .name("Craft Scheduler Thread - ", 0) ++ .uncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)) ++ .factory() ++ ); ++ + return; + } + + executor = new ThreadPoolExecutor( + 4, Integer.MAX_VALUE, 30L, TimeUnit.SECONDS, new SynchronousQueue<>(), -+ new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); ++ new ThreadFactoryBuilder() ++ .setNameFormat("Craft Scheduler Thread - %1$d") ++ .setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)) ++ .build()); + + var threadPoolExecutor = (ThreadPoolExecutor) executor; +