better termination

This commit is contained in:
2025-04-12 13:04:48 +02:00
parent de733fcea2
commit 39c289cc47
4 changed files with 18 additions and 6 deletions

View File

@@ -98,4 +98,7 @@ public class CommandExecutor {
this.game = game;
}
public void close() {
this.dispatcher.stopService();
}
}

View File

@@ -2,7 +2,7 @@ package chess.controller.event;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
@@ -12,7 +12,7 @@ import chess.model.Coordinate;
public class GameDispatcher implements GameListener{
private final List<GameListener> listeners;
private final Executor executor;
private final ExecutorService executor;
public GameDispatcher() {
this.listeners = new ArrayList<>();
@@ -71,5 +71,9 @@ public class GameDispatcher implements GameListener{
public void updateDisplay() {
asyncForEachCall((l) -> l.updateDisplay());
}
public void stopService() {
this.executor.shutdown();
}
}