Originally posted by Vlad Rabkin:
Cool, one more supporter! Max where are you? Come back on the ring, let's fight, now I am not alone!
"I'm not back." - Bill Harding, Twister
So, because thread_1 needs to stay in the wait pool, notifyAll() is used? How does notifyAll() help something stay in the wait pool? Isn't it used to help move something out of the wait pool? (Perhaps only temporarily, as the wait() is inside a loop, but still...)And why would thread_1 benefit from moving out of the wait pool when something was locked (either record -1 or another record)? Isn't thread-1 only interested in waking up when at least one record (or rec -1) is unlocked? What exactly is thread_1 going to do when it is awoken by notifyAll() immediately after something else has been locked? How does the new lock help?
Does this last post have anything to do with Max's earlier claim that a thread entering a sync block for the very first time might somehow benefit from receiving a notifyAll()? Has that argument been withdrawn, or does it have some role in the explanation given in this last past?
[ October 02, 2003: Message edited by: Jim Yingst ]
The issue is that there are threads who are trying just about to enter the synchronization block for the very first time, even as other threads have already done do. These (newbie) threads are blocked, because another thread currently has the monitor for reservedRecords. Now, when that thread calls notifyAll, then the threads who are trying to get the lock on reservedRecords for the very first time will get an opportunity to do so.
"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
[Max]: Depending on your implementation decision, Thread_1 may simply choose to give up trying to lock record_1: thus, it would need to know that some other thread had locked record -1. Not an idea I recommended, but defendable.
OK, I see how this could fit in now, for some possible designs. Thanks.
I think I failed to be clear. Of course I didn't mean that threads that have never waited by calling the map.wait method will benefit from a call to notifyAll. I meant threads like the above, which have yet to achieve the record. The terminology here is somewhat unsettling, because there are dual concepts of wait. There is waiting to enter a synchronized block, and there is the waiting by calling object.wait. My apologies if I failed to be clear.
OK, cool. I was looking at this quote:
This seemed to be explicitly talking about threads trying to enter sync blocks, rather than threads which were in wait(). This was the main issue I was disagreeing with you on. As long as we're only talking about notifyAll() affected threads which are in wait(), then this is now resolved. Thanks again...
Thread_1 may simply choose to give up trying to lock record_1: thus, it would need to know that some other thread had locked record -1.
Originally posted by Vlad Rabkin:
Hi Max and Jim,
Finally, finally I understand it!!!
Thank you !
Vlad
"I'm not back." - Bill Harding, Twister
Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
I'm not sure if I approve of this interruption. But this tiny ad checks out:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
|