Skip to content

Commit 7af5f8b

Browse files
authored
Merge pull request WearBlackAllDay#16 from manugame/master
Fixes WearBlackAllDay#14
2 parents 194c174 + c4b9740 commit 7af5f8b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/java/dimthread/mixin/MinecraftServerMixin.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,13 @@ public void tickWorlds(BooleanSupplier shouldKeepTicking, CallbackInfo ci) {
7777
crash.get().crash("Exception ticking world");
7878
}
7979
}
80-
80+
81+
/**
82+
* Shutdown all threadpools when the server stop.
83+
* Prevent server hang when stopping the server.
84+
* */
85+
@Inject(method = "shutdown", at = @At("HEAD"))
86+
public void shutdownThreadpool(CallbackInfo ci) {
87+
DimThread.MANAGER.threadPools.forEach((server, pool) -> pool.shutdown());
88+
}
8189
}

src/main/java/dimthread/util/ServerManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class ServerManager {
1414

1515
private final Map<MinecraftServer, Boolean> actives = Collections.synchronizedMap(new WeakHashMap<>());
16-
private final Map<MinecraftServer, ThreadPool> threadPools = Collections.synchronizedMap(new WeakHashMap<>());
16+
public final Map<MinecraftServer, ThreadPool> threadPools = Collections.synchronizedMap(new WeakHashMap<>());
1717

1818
public boolean isActive(MinecraftServer server) {
1919
return this.actives.computeIfAbsent(server, s -> s.getGameRules().get(ModGameRules.ACTIVE.getKey()).get());

0 commit comments

Comments
 (0)