>>>>> "Sylvia" == Sylvia Else <firstname.lastname@example.org> writes:
Sylvia> 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.
Sylvia> All the actions performed by the loop happen-before the setting of
Sylvia> workerFinished to true. Any thread that reads true from workerFinished must
Sylvia> see the effects of all the actions that happen-before it, which includes
Sylvia> the processing of the work in the buffer.
Sylvia> I don't see the problem.
I would agree. The interesting case in this context is where the loop does
only thread-private work, perhaps only on local variables all of which have
been allocated to registers .... EM
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