• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to control more than two threads using wait() and notify() in ThreadConcept

 
sajja bala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope a quick response :roll:
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to be a little more specific in your questions. Don't expect quick responses to such vague queries.
 
abhishek pendkay
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your question is not clear but i would still make one point and that is notify cannot be used to control any particular thread... it will just randomly choose a thread from the wait pool and make it runnable...
so if you can be more specific and mention what do you exactly mean by "control threads" maybe you will get an answer
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by abhishek pendkay:
notify cannot be used to control any particular thread...

Well, what if i have a single thread waiting on that monitor?
In such a case, notify() does control that particular thread. isnt?
 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if it is the only thread that is waiting, then you are pretty much guaranteed that notify() will select it. The point is that notify() doesn't allow you to target a specific thread. notify picks one and notifies it. notifyAll() just notifies them all and let's the thread scheduler figure out who to dispatch.
 
abhishek pendkay
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i agree with Nitesh and Bob but if you have a look at the original question he is talking about controling more than two threads so my post was with that respect....
i understand that my choice of words was not very appropriate so no more confusions i guess..!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!