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