diff --git a/.classpath b/.classpath
index be377dd..ae30f86 100644
--- a/.classpath
+++ b/.classpath
@@ -6,12 +6,6 @@
-
-
-
-
-
-
@@ -19,13 +13,6 @@
-
-
-
-
-
-
-
diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs
index f11e4b7..3630cfc 100644
--- a/.settings/org.eclipse.buildship.core.prefs
+++ b/.settings/org.eclipse.buildship.core.prefs
@@ -1,4 +1,4 @@
-arguments=--init-script /home/libkyy/.cache/jdtls/config/org.eclipse.osgi/51/0/.cp/gradle/init/init.gradle
+arguments=--init-script /home/linly/.cache/jdtls/config/org.eclipse.osgi/52/0/.cp/gradle/init/init.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
diff --git a/src/main/java/org/bootcamp/TrafficLights/Traffic.java b/src/main/java/org/bootcamp/TrafficLights/Traffic.java
index dc52364..9130233 100644
--- a/src/main/java/org/bootcamp/TrafficLights/Traffic.java
+++ b/src/main/java/org/bootcamp/TrafficLights/Traffic.java
@@ -7,6 +7,7 @@ public class Traffic {
public static boolean pressed = false;
public static void main(String[] args) {
+ // Countdowns
// Lights
Redlight redlight = new Redlight();
Yellowlight yellowlight = new Yellowlight();
@@ -19,9 +20,9 @@ public class Traffic {
Traffic_Sign.add(greenlight, 2);
// Threads
- Thread red_thread = new Thread(redlight);
- Thread yellow_thread = new Thread(yellowlight);
- Thread green_thread = new Thread(greenlight);
+ // Thread red_thread = new Thread(redlight);
+ // Thread yellow_thread = new Thread(yellowlight);
+ // Thread green_thread = new Thread(greenlight);
// Button
JButton StopButton = new JButton("STOP");
StopButton.addActionListener(
@@ -31,13 +32,31 @@ public class Traffic {
Traffic_Sign.add(StopButton, 3);
while (true) {
+ Thread red_thread = new Thread(redlight);
+ Thread yellow_thread = new Thread(yellowlight);
+ Thread green_thread = new Thread(greenlight);
red_thread.start();
+ try {
+ red_thread.join();
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
if (pressed)
break;
yellow_thread.start();
+ try {
+ yellow_thread.join();
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
if (pressed)
break;
green_thread.start();
+ try {
+ green_thread.join();
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
if (pressed)
break;
}
diff --git a/src/main/java/org/bootcamp/TrafficLights/Yellowlight.java b/src/main/java/org/bootcamp/TrafficLights/Yellowlight.java
index 12d8879..1309b1a 100644
--- a/src/main/java/org/bootcamp/TrafficLights/Yellowlight.java
+++ b/src/main/java/org/bootcamp/TrafficLights/Yellowlight.java
@@ -5,6 +5,6 @@ import java.awt.Color;
public class Yellowlight extends Light {
Yellowlight() {
- super(5, Color.YELLOW);
+ super(2, Color.YELLOW);
}
}