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

From: Doug Lea (dl@altair.cs.oswego.edu)
Date: Wed Jan 02 2002 - 12:04:34 EST


To restate what I think Bill is saying, in order to guarantee
that
  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.

-Doug
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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