mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 06:49:27 +00:00
fix ExecutorShutdown error, closes #44
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user