[sarvesh meens]: The thread comes out of wait the first time due to spurious wake-up.
[Nitesh]: Oh man, thats interesting. So, how did you come to that conclusion? I really don't think there's any reason to think this is the case. Spurious wakeup is something that
can happen, according to the spec (at least since JLS 3rd edition, anyway - see
17.8.1) but it's generally rare, and on some platforms may
never occur. It
is something that should be allowed for as a possibility though, and that's one reason why wait() should alwas be performed in a loop that checks a condition, as sarvash showed. I think this is just a miscommunication - sarvash said that spurious wakeup
does happen when he (or she?) meant that it
can happen. Of course I may be mistaken, and I hope sarvash will let us know if that's the case.
[ December 16, 2007: Message edited by: Jim Yingst ]