jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Help correct this calculator thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Help correct this calculator thread" Watch "Help correct this calculator thread" New topic

Help correct this calculator thread

Anthony Karta
Ranch Hand

Joined: Aug 09, 2004
Posts: 342
I feel the calculator sample in K&B book chapter 9 (thread) does not show the wait/notify scenario properly. I'm trying to modify it but got stuck now.

The idea is Calculator thread is waiting for a reader, who will send values to be powed (not implemented for now).

thanks all

Henry Wong

Joined: Sep 28, 2004
Posts: 18498

First, your calculator instance never set the reader reference, so synchronizing on the "r" variable (which is not set) just doesn't work. Second, your calculator instance is shared amoung many readers. You will have to synchronize and wait, on the correct reader to work.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link: http://aspose.com/file-tools
subject: Help correct this calculator thread
Similar Threads
notify and notifyAll
wait and notify
Threading discrepancies
dubt in notifyAll
wait(), notify(), notifyAll() doubt