|
|
|
|
Now, let's go back to our SteamBoiler class, and change the burn() method in class Burner to:
The only change is to surround the code with a synchronized statement, specifying the instance of SteamBoiler as the object on which to synchronize. Why did I choose to synchronize on the instance of SteamBoiler? Why did I not simply make the burn() method synchronized? To show it works, here's the fixed SteamBoilerApplet:
|
| The page was last updated February 19, 2008 |