Project 11

You are to do Programming Exercise 24.4 on page 812 of the textbook. But there are some comments and additions.

  1. The textbook talks about passing a variable by reference. What this means will be discussed in class. It says to use an Integer wrapper object. Unless I'm missing something, this cannot be the Integer class of Java, because an Integer object, once created, can't be changed.
  2. Instead of Integer, you can use a simple class I created, called MyInteger. This will be discussed in class.
  3. The exercise calls for you to run the program with and without synchronization to see its effect. In addition: write a short paragraph explaining the effect you see. That is, if synchronization changes things, explain why. If it doesn't change anything, explain why it doesn't.

Solution