From 2a81a0342e7975b2b9268d1e464e7d1dc833c7af Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Tue, 28 Apr 2020 22:32:16 +0200 Subject: [PATCH] Spiel wird als eigener Thread gestartet --- src/gfn/marc/TicTacToe.java | 44 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/gfn/marc/TicTacToe.java b/src/gfn/marc/TicTacToe.java index e6bbf00..854dba3 100644 --- a/src/gfn/marc/TicTacToe.java +++ b/src/gfn/marc/TicTacToe.java @@ -9,30 +9,38 @@ public class TicTacToe { static Fenster f; static boolean DEBUG = true; + static Thread spiel = new Thread(new Runnable() { + @Override + public void run() { + try { + //f = null; + f = new Fenster(); + boolean nochEinSpiel = true; + while (nochEinSpiel) { - public static void main(String[] args) throws IOException { + nochEinSpiel = new Spiel(f).spielen(); + + // aufräumen + //f.setVisible(false); + Gewinner.setSpieler(null); + Zug.setZugNummer(0); + f.getSpielfeld().reset(); + + } + } catch (InterruptedException ie) { + System.err.println("Da ist was schief gelaufen!"); + } + } + }); + + public static void main(String[] args) throws IOException, InterruptedException { // Laden der Spielstände Speicher.spielstaendeEinlesen(); // Spiel starten - try { - boolean nochEinSpiel = true; - while (nochEinSpiel) { - - f = null; - f = new Fenster(); - nochEinSpiel = new Spiel(f).spielen(); - - // aufräumen - f.setVisible(false); - Gewinner.setSpieler(null); - Zug.setZugNummer(0); - - } - } catch (InterruptedException ie) { - System.err.println("Da ist was schief gelaufen!"); - } + spiel.start(); + spiel.join(); Speicher.spielstaendeSpeichern(); System.exit(0); // sofortiges Programmende