diff --git a/src/UE20_290425_Threads2/Horse.java b/src/UE20_290425_Threads2/Horse.java index a3d3c88..c97fff9 100644 --- a/src/UE20_290425_Threads2/Horse.java +++ b/src/UE20_290425_Threads2/Horse.java @@ -7,7 +7,7 @@ import static UE20_290425_Threads2.Pferderennen.textArea; public class Horse extends ProgressBar implements Runnable { private static final double finish_line = 1_000_000; - private static final double maxSleepTime = 100, maxStepSize = 10_000; + private static final double maxSleepTime = 1, maxStepSize = 10_000; private final int index; private double pos = 0; @@ -16,10 +16,6 @@ public class Horse extends ProgressBar implements Runnable { this.index = index; } - public double getPos() { - return this.pos; - } - public void setPos(double pos) { this.pos = pos; } diff --git a/src/UE20_290425_Threads2/Pferderennen.java b/src/UE20_290425_Threads2/Pferderennen.java index ec4b5e2..3864eaa 100644 --- a/src/UE20_290425_Threads2/Pferderennen.java +++ b/src/UE20_290425_Threads2/Pferderennen.java @@ -18,13 +18,14 @@ public class Pferderennen extends Application { protected static final TextArea textArea = new TextArea(); protected static final ArrayList horses = new ArrayList<>(); private static final ArrayList threads = new ArrayList<>(); - private static boolean lock = false, reset = false; + private static boolean lock = false; public static void main(String[] args) { launch(args); } private static void startRace() { + for (Horse horse : horses) horse.setPos(0); threads.clear(); for (Horse horse : horses) { Thread thread = new Thread(horse); @@ -49,24 +50,18 @@ public class Pferderennen extends Application { BorderPane backPane = new BorderPane(); Label titel = new Label("Pferderennen - mit Threads"); -// titel.setStyle("-fx-font-size: 16px;"); backPane.setTop(titel); -// BorderPane.setAlignment(titel, CENTER); VBox button_box = new VBox(10); -// button_box.setPadding(new Insets(10)); Button button_plus = new Button("+"); Button button_minus = new Button("-"); button_box.getChildren().addAll(button_plus, button_minus); backPane.setLeft(button_box); - // Rechts: Start-Button Button button_start = new Button("Start"); VBox start_box = new VBox(button_start); start_box.setPadding(new Insets(10)); -// start_box.setSpacing(10); backPane.setRight(start_box); -// VBox.setMargin(button_start, new Insets(5)); textArea.setPrefRowCount(10); textArea.setEditable(false); @@ -98,16 +93,14 @@ public class Pferderennen extends Application { textArea.appendText("Please wait for the race to finish\n"); return; } - for (Horse horse : horses) horse.setProgress(0); lock = true; textArea.appendText("Ergebnis:\n"); startRace(); }); - // Scene und Stage Scene scene = new Scene(backPane, 600, 400); stage.setTitle("Pferderennen"); stage.setScene(scene); stage.show(); } -} +} \ No newline at end of file