RE: JavaMemoryModel: Performing speculative writes ahead of loops that may not terminate

From: David Holmes (dholmes@dltech.com.au)
Date: Sun May 30 2004 - 23:14:47 EDT


I wrote:
> The loop need not use the buffer at all - the worker could read data from
> the buffer then enter a processing loop on the read data (say numeric
> values) and the loop then becomes of the form:
>
> while (!converged) processData();
> workerFinished = true;
>
> processData could be purely thread-local actions.

Of course the simple way to make the write after the loop significant is for
it to be a value calculated in the loop.

   int result;
   while(!converged) result = processData();
   answer = result; // volatile write of result of computation

David Holmes

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



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