[concurrency-interest] spurious wakeups semantics

Gregg Wonderly gergg at cox.net
Wed Nov 2 10:45:11 EST 2005


P.H.Welch wrote:
> which is actually what they really are anyway ... with no guarantees
> of exit.  I suspect that many real systems running on many real JVMs
> (even without spurious wakeups) are at risk from never exiting such
> loops.  Isn't the *only* technical reason for programming such loops
> ... to cope with spurious wakeups?  The other reasons for them being
> lazy (or erroneous) logic ... that's a conjecture ... suspect true.
> 
> Isn't it time that spurious wakeups were removed from Java semantics?

I regularly code

	synchronized(lock) {
		while(!cond) {
			lock.wait(10000);
			log.fine("lock wakeup, cond: "+cond );
		}
	}

to make sure that if I see a no-progress situation, I can check to see which 
threads are stuck with conditions not changing (see my http://logman.jini.org 
project that lets you use jini to remotely manage and monitor logging streams). 
  This is a good debugging aid, and it helps me to manage all the interactions 
that I expect to see during testing.  I can turn this debugging on, and see that 
things are flowing as expected.  One can specify an even shorter sleep time, and 
get more log messages which can help alert you to longer than expected waiting.

Gregg Wonderly


More information about the Concurrency-interest mailing list