Write a JAVA program SimRace, which uses threads to simulate a car race. The
Class SimRace should define the number of cars and the length of the track (in laps) as constants and take on the role of “race control”.
Directly after an auto thread (class Car) has been generated, it can be started by the race management.
The simulated cars should move in such a way that the time required for one lap is determined by a random number (“random”), i.e. after each “driven” lap the time for
the next round is “rolled” (0 <= round time < 100 ms) and the auto-thread is stopped. Je -
of the car is to measure its own total driving time.
As soon as all cars have crossed the finish line (not before!), the race director should display a total results table on the console, in which the cars are placed in the order they are placed with the corresponding required -
ten total driving time can be output.
Example of a 5 car race:
**** Final Score ****
Place: Car 1 Time: 376
Place: Car 0 Time: 478
Place: Car 3 Time: 546
Place: Car 2 Time: 611
Place: Car 4 Time: 626
Hints:
Use (sleep(), join(), …) as a guide!
Each thread can access all public variables of all classes and the public methods of all classes
run (if not prevented by synchronization mechanisms).
The deprecated stop, suspend, and resume methods must not be used, and should not be used
Do not use the wait and notify synchronization functions here.