Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Through its implementation, this project will familiarize you with the creation and execution of threads, and with the use of the Thread class methods. In
Through its implementation, this project will familiarize you with the creation and execution of threads, and with the use of the Thread class methods. In order to synchronize the threads you will have to use (when necessary), run(), start( ), currentThread(), getName), join(), yield( ), sleep(time), isAlive(), getPriority), setPriority(), interrupt(), islnterrupted(), and maybe synchronized methods In synchronizing threads, DO NOT use any semaphores. DO NOT use wait(), notifv() or notifyAll): In the next story they are two types of threads: racer and judge The Race A number of racers will compete in a race with three obstacles: The Forest, The Mountain and The River. Before the first obstacle and between any two obstacles, the racers will stop for rest and food (by sleeping for a random time). The sequence of events will be something similar to Rest Forest Rest Mountain Rest River Get Home Note: you will need to keep track of the time when a racer started a specific obstacle and when it ended that obstacle, together with the time when the racer started the race until he finished the race The obstacles are described below: The Forest: You will have to use the setPriority(), getPriority() and yield() methods At the entry to the forest, the racer will try to rush as much as possible (simulated by increasing its current priority by a randomly generated number between 0-4) Through its implementation, this project will familiarize you with the creation and execution of threads, and with the use of the Thread class methods. In order to synchronize the threads you will have to use (when necessary), run(), start( ), currentThread(), getName), join(), yield( ), sleep(time), isAlive(), getPriority), setPriority(), interrupt(), islnterrupted(), and maybe synchronized methods In synchronizing threads, DO NOT use any semaphores. DO NOT use wait(), notifv() or notifyAll): In the next story they are two types of threads: racer and judge The Race A number of racers will compete in a race with three obstacles: The Forest, The Mountain and The River. Before the first obstacle and between any two obstacles, the racers will stop for rest and food (by sleeping for a random time). The sequence of events will be something similar to Rest Forest Rest Mountain Rest River Get Home Note: you will need to keep track of the time when a racer started a specific obstacle and when it ended that obstacle, together with the time when the racer started the race until he finished the race The obstacles are described below: The Forest: You will have to use the setPriority(), getPriority() and yield() methods At the entry to the forest, the racer will try to rush as much as possible (simulated by increasing its current priority by a randomly generated number between 0-4)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started