Assignment-04

 

 

 

Foreword

Resources

Code Listings

Foil Sets

Assignments

Solutions

External Resources

SiteMap

Search

Home

Up ] Assignment-01a ] Assignment-01b ] Assignment-01c ] Assignment-01d ] Assignment-02 ] Assignment-02a ] Assignment-03 ] Assignment-03a ] Assignment-03b ] Assignment-03c ] Assignment-03d ] [ Assignment-04 ] Assignment-04a ] Assignment-04b ] Assignment-05 ] Assignment-06 ] Assignment-07 ]

Writing a Java applet with multithreading

  1. You may choose to design your own applet with multithreading and synchronization. Be sure to include a use of the wait() and notify() methods.
  2. or try the following applet:

    The Tortoise and the Hare Race

    Look at the example problem 13.17 on page 728 of the Deitel textbook. This problem is to implement a "tortoise and hare" race in which the tortoise and the hare are each controlled by a thread. The rules for the moves of the tortoise and the hare are described in problem 5.41 on page 279. You should simulate the race generating moves as described here, except that instead of printing out the progress of the race, you should have an applet visualization of the progress of the race. You can draw the racecourse in the applet window and show the progress of the tortoise and the hare at each clock tick.

    Note that you will need to synchronize the threads with wait and notify so that neither thread goes past one tick of the clock until the other thread is ready, too.