Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help correct this calculator thread  RSS feed

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Sheriff
Posts: 22836
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!