Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

wait() and notify()

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
which object should be marked synchronized when we want a thread to wait??

how does a thread know which object amongst those which are waiting to notify??
 
Ranch Hand
Posts: 537
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Well on what you want to wait that decides what need to be synchronized. Well if you are waiting on an object for something, so someone should notify on that object only. Also objects are not waiting,its the threads that are waiting.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Duplicate topic...

https://coderanch.com/t/459168/Threads-Synchronization/java/wait-notify


Please do not crosspost. It wastes people time and effort.

Henry
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic