| 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.
|
 |
 |
|
|
subject: multiple waiting threads. only one notified
|
|
|