Originally posted by Matt Cannata:
It also causes wasteful cycles by waking up threads unnecessairly. Example: Clients 1-5 are waiting or record 5. Client 6 releases lock or record 1 and calls notifyAll. Clients 1-5 get notified, since they were all waiting on the same object (Data) and all of them try to get record that is still unavailable.
Originally posted by Matt DeLacey:
Rahul,
I believe that you are absolutely right. Thanks for pointing this out to me. Not sure how it escaped me. I was thinking of locking on a wrapped version of the record rather than on a collections class. I don't like at all the idea of two clients who want separate records having to wait on one another. I will explore my other idea now. Thanks again.
With Respect,
Matt DeLacey
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |