This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [win32] notifyAll also notifying following wait calls


>>>>> "Marco" == Marco Trudel <mtrudel@gmx.ch> writes:

>> But note that Object.wait() can wake up spuriously.  So...

Marco> How so? Wouldn't that make the whole wait() notify() mechanism pretty
Marco> useless?

I'm just saying, Object.wait() is allowed to wake up spuriously.  I
haven't looked deeply into why it might be defined this way.  It
definitely isn't useless, it is just that the way to use it is a bit
different from what one might first expect.

Marco> mainLock.wait(); // not allowed to be notified
>> ... I think this comment is incorrect.

Marco> It is allowed to be notified from the preceding notifyAll() call?

I didn't read that closely, since it can wake up for no reason at all.
User code has to expect this, which is why the proper way to use
wait() is to call it in a loop and then check some external condition
before exiting the loop.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]