9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00

fix ExecutorShutdown error, closes #44

This commit is contained in:
NONPLAYT
2025-12-14 15:11:13 +03:00
parent bd1acbc1ab
commit c74ca05912
3 changed files with 6 additions and 6 deletions

View File

@@ -9,12 +9,12 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class AsyncChunkSend {
public static final ExecutorService POOL = new ThreadPoolExecutor(
public static final ExecutorService POOL = DivineConfig.AsyncCategory.asyncChunkSendingEnabled ? new ThreadPoolExecutor(
1, DivineConfig.AsyncCategory.asyncChunkSendingMaxThreads, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
new NamedAgnosticThreadFactory<>("Async Chunk Sending", AsyncChunkSendThread::new, Thread.NORM_PRIORITY),
new ThreadPoolExecutor.CallerRunsPolicy()
);
) : null;
public static class AsyncChunkSendThread extends Thread {
protected AsyncChunkSendThread(ThreadGroup group, Runnable task, String name) {

View File

@@ -24,14 +24,14 @@ public class AsyncPathProcessor {
private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX);
private static long lastWarnMillis = System.currentTimeMillis();
public static final ThreadPoolExecutor PATH_PROCESSING_EXECUTOR = new ThreadPoolExecutor(
public static final ThreadPoolExecutor PATH_PROCESSING_EXECUTOR = DivineConfig.AsyncCategory.asyncPathfinding ? new ThreadPoolExecutor(
1,
DivineConfig.AsyncCategory.asyncPathfindingMaxThreads,
DivineConfig.AsyncCategory.asyncPathfindingKeepalive, TimeUnit.SECONDS,
getQueueImpl(),
new NamedAgnosticThreadFactory<>(THREAD_PREFIX, TickThread::new, Thread.NORM_PRIORITY - 2),
new RejectedTaskHandler()
);
) : null;
private static class RejectedTaskHandler implements RejectedExecutionHandler {
@Override

View File

@@ -29,14 +29,14 @@ public class MultithreadedTracker {
private static final Logger LOGGER = LogManager.getLogger(THREAD_PREFIX);
private static long lastWarnMillis = System.currentTimeMillis();
public static final ThreadPoolExecutor TRACKER_EXECUTOR = new ThreadPoolExecutor(
public static final ThreadPoolExecutor TRACKER_EXECUTOR = DivineConfig.AsyncCategory.multithreadedEnabled ? new ThreadPoolExecutor(
getCorePoolSize(),
getMaxPoolSize(),
getKeepAliveTime(), TimeUnit.SECONDS,
getQueueImpl(),
getThreadFactory(),
getRejectedPolicy()
);
) : null;
public static void tick(ServerLevel level) {
try {