This commit is contained in:
2025-05-13 11:29:45 +02:00
parent be7ee00a03
commit 14c5ef09f5
3 changed files with 86 additions and 18 deletions

View File

@@ -1,8 +1,26 @@
package UE21_290425_Bruecke;
public class Generator {
public static void main(String[] args) {
Guard guard = new Guard();
public class Generator extends Thread {
public static boolean RESUME = true;
private static Guard guard = new Guard();
private static Generator generator = new Generator();
public static void main(String[] args) {
generator.start();
guard.start();
}
@Override
public void run() {
while (Generator.RESUME) {
try {
Thread.sleep((int) (Math.random() * 5 + 1) * 1000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Car car = new Car(guard);
guard.arriving(car);
System.out.println(guard);
}
}
}