Bookmark Topic Watch Topic
  • New Topic

wait(), notify(), notifyAll()  RSS feed

 
velmurugan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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.
 
Jeremy Botha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • 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
Boost this thread!