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,5 +1,25 @@
package UE21_290425_Bruecke;
public class Car {
import java.time.LocalTime;
public class Car extends Thread {
private static final int crossingTime = 50_000;
LocalTime arrivingTime;
Guard guard;
public Car(Guard guard) {
this.guard = guard;
this.arrivingTime = LocalTime.now();
}
@Override
public void run() {
try {
Thread.sleep(crossingTime);
guard.leaving();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}