on 09-16-2006 2:53 PM
Hi,
Can any body tell me
Whats the difference between notify() and notifyAll()?
Thank you,
Rajesh.N
Hi,
notify() is used to unblock one waiting thread.
notifyAll() is used to unblock all of them.
notify() is preferable for performance when only one blocked thread can benefit from the change .
for example, when freeing a buffer back into a pool.And notifyAll() is necessary for correctness if multiple threads should resume .For example, when releasing a writer lock on a file might permit all readers to resume.
With regards,
Suman Sahu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check out the link
http://www.codecomments.com/archive245-2005-12-727949.html
notifyAll() wakes up ALL waiting threads; the scheduler decides which one will run.
notify() is used to unblock one waiting thread; notifyAll() is used to unblock all of them. Using notify() is preferable (for efficiency) when only one blocked thread can benefit from the change (for example, when freeing a buffer back into a pool). notifyAll() is necessary (for correctness) if multiple threads should resume (for example, when releasing a writer lock on a file might permit all readers to resume).
Regards,
Richa.<a href="http://www.codecomments.com/archive245-2005-12-727949.html">link</a>
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.