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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

wait(), notify(), notifyAll()

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi everybody,

We all know that wait(), notify(), notifyAll() methods are related to Thread

What is the the need for having these 3 methods belongs Object class?

Please explain me.
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This has been covered before.

In short, it's because most people like the ability to use objects that are not direct subclasses of Thread as lock objects for synchronization. If you take the time to think the issues through, you'll realise that an object like a Database connection pool store might not need to run in a thread, but still requires synchronization on its getConnection and releaseConnection methods.

Rather than creating a new Thread to synchronize off; doesn't it make sense to just be able to call dbConnectionPool.wait() and dbConnectionPool.notifyAll()?

J
    Bookmark Topic Watch Topic
  • New Topic