Files
SEW_Uebungen_2024.25/src/UE21_290425_Bruecke/Generator.java
2025-05-13 11:29:45 +02:00

27 lines
714 B
Java

package UE21_290425_Bruecke;
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);
}
}
}