better termination
This commit is contained in:
@@ -98,4 +98,7 @@ public class CommandExecutor {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.dispatcher.stopService();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user