• Post Reply Bookmark Topic Watch Topic
  • New Topic

notify  RSS feed

 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the below code if i don't use notiy butresult don't change.why?
if one thread wait other shouldn't be notify?

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since both classes synchronize on the same object, this code can't work. Either the calculation (and the "notify" call) happen before the calling class ever issues the "wait" (thus ensuring that it can never wake up), or the "wait" occurs before the calculation is started (thus ensuring that it can never wake up).

Moving to a more appropriate forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!