This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes multiple waiting threads. only one notified Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "multiple waiting threads. only one notified" Watch "multiple waiting threads. only one notified" New topic
Author

multiple waiting threads. only one notified

duck worth
Greenhorn

Joined: Jul 26, 2009
Posts: 2
Hi all,

Easy-peasy one for somebody. You have multiple threads calling waiting for another thread. But that thread only calls notify(). Hence only tells one of the waiting threads the lock is going to become available. What happens to the other poor threads. Do they wait forever more???

Duck out
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
They'll wait until notify is called again. Or notifyAll is called.


JDBCSupport - An easy to use, light-weight JDBC framework -
duck worth
Greenhorn

Joined: Jul 26, 2009
Posts: 2
so basically, if the thread never calls it again they're stuck. Suppose that leaves it down to sensible code design

many thanks
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Yes, they are stuck.

But the wait method is overloaded to take a long value that specifies the time limit in milliseconds. if this is exceeded, it simply carries on.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: multiple waiting threads. only one notified
 
Similar Threads
java biginer
URLyBird 1.3.1: Locking Problem
Using record cache and booking method
B&S Data => Lock-waiting giveup CPU
Notify vs Notify All