RE: JavaMemoryModel: Guaranteed semantics for Thread.yield()

From: Doug Lea (
Date: Wed Jan 02 2002 - 12:04:34 EST

To restate what I think Bill is saying, in order to guarantee
  volatile x = 0;
  while (x == 0) Thread.yield();
does what any programmer would expect, we need to do one of the following:
  1. Define memory semantics for yield()
  2. Guarantee that an infinite number of yield()s causes at least one
     actual yield.

Can anyone think of any alternatives?

I think that Bill is right that (2) is a better path.

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:36 EDT