At 09:36 PM 30/05/2004 +1000, David Holmes wrote:
>Master thread fills in a buffer with work items and then starts a new worker
>thread to process the buffer. Worker threads executes:
> while (!buf.empty()) process(buf.take());
> workerFinished = true;
>where workerFinished is a volatile. Not quite as dramatic as firing the
>missiles, but same basic problem.
All the actions performed by the loop happen-before the setting of
workerFinished to true. Any thread that reads true from workerFinished must
see the effects of all the actions that happen-before it, which includes
the processing of the work in the buffer.
I don't see the problem.
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