Question: You are going to write a program that runs a race between a tortoise and a hare. You might recognize this story from your childhood.
You are going to write a program that runs a race between a tortoise and a hare. You might recognize this story from your childhood. The turtle will be represented by a class that extends the Thread class. The hare will be represented by a class that implements the Runnable interface. Create a Race class where both animals run a race around laps. Each lap it will print animal name here running lap until they finish the race. Then print who won the race. That is represented by which thread finished first. Use Synchronization concepts, notify concepts, etc to control the race. Create your program to ensure that the tortoise wins then adjust it so that the hare wins.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
