Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Errata v2 - Updated errata for Kathy and Bert's book

 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody ever write a 711 page program?
We'd like everyone to know that we've just posted Version 2 of our errata page on www.wickedlysmart.com.
And...
In the next few days, we'll be announcing a new Java contest (did we say this a few days ago?) !!! More prizes, more fun !
Stay tuned !
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 533, Bottom code block 2/07/03

Change:

20. calculator.start();
21. new Reader(calculator).start();
22. new Reader(calculator).start();
23. new Reader(calculator).start();

To:

20. new Reader(calculator).start();
21. new Reader(calculator).start();
22. new Reader(calculator).start();
23. calculator.start();

Thank you very much for the errata, Bert! Here I have a question: The corrected code above worked find and I understand it. But why didn't the original code work well? I complied the both and the first one stuck after printed 3 lines of "waiting for calculation...". Why? Thank you.
 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wow are you up to page 533 Ellen? just started on it myself, i am up to page 50. seems like a good book!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[b]The Ellen formerly known as Fu wrote:

And the Reader:

Thus, each Reader checks to see if the calculation has already been completed, immediately before executing a wait. And even if it receives a notifyAll(), it rechecks to see if the calculation really is done. The recheck may be unnecessary if you are certain that the only code that could possibly call notify/notifyAll is the code that is run when the calculator is done. However it's good to get in the habit of putting this check in a loop, as on more complex systems there may be other reasons notify is called, and it's hard to keep track of everything. See Joshua Bloch's Effective Java, "Item 50: Never invoke wait() outside a loop", for more info. This book is highly recommended for the other 56 items as well.
Of course, if the book example was not about a wait/notify protocol, you can just ignore this post.
[ February 15, 2003: Message edited by: Jim Yingst ]
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim,
Well spotted, exactly like what you said. Now the picture is clear to me. Thank you very much for your respond!
Ignore? Oh no...there's usually bonus for me to read your posts answering questions submitted by others which had nothing to do with my own work, there's not only simple fact but more...no way ignore
To Jasper,
No, several exams are dominating me concurrently now, I'm just like a CPU doing Round-Robin time slicing...have done with Chapter 9 and 1 of Kathy and Bert's book, planned to take this exam in late March.
Regards,
Ellen
 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ellen Zhao:
several exams are dominating me concurrently now, I'm just like a CPU doing Round-Robin time slicing...

well, that certainly implies that you are in touch with more than just your own personal inner-JVM ... in the sense that the issue of whether a system performs time-slicing is jvm-independent.
good luck with the tough german exams!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic