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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic