diff --git a/src/main/java/seng302/visualiser/ClientToServerThread.java b/src/main/java/seng302/visualiser/ClientToServerThread.java index e2eb7687..c387ff46 100644 --- a/src/main/java/seng302/visualiser/ClientToServerThread.java +++ b/src/main/java/seng302/visualiser/ClientToServerThread.java @@ -145,12 +145,14 @@ public class ClientToServerThread implements Runnable { } } catch (ByteReadException e) { closeSocket(); - Platform.runLater(() -> { - Alert alert = new Alert(AlertType.ERROR); - alert.setHeaderText("Host has disconnected"); - alert.setContentText("Cannot find Server"); - alert.showAndWait(); - }); + if (Platform.isFxApplicationThread()) { + Platform.runLater(() -> { + Alert alert = new Alert(AlertType.ERROR); + alert.setHeaderText("Host has disconnected"); + alert.setContentText("Cannot find Server"); + alert.showAndWait(); + }); + } clientLog(e.getMessage(), 1); return; }