[concurrency-interest] Quick question on ConcurrentLinkedQueue
dl at cs.oswego.edu
Mon Apr 9 08:04:04 EDT 2007
Joseph Seigh wrote:
> Hanson Char wrote:
>> Say we have two initially empty j.u.c.ConcurrentLinkedQueue, clq1 and
>> clq2. If two threads offered to each queue individually at the same
>> time, followed by polling the other queue, is it possible for both
>> threads to observer the other queue as being empty ?
>> In other words:
>> Time Thread1 Thread2
>> 0 clq1.offer clq2.offer
>> 1 x=clq2.poll y=clq1.poll
>> Can both x and y be null ?
> No. ConcurrentLinkedQueue contains volatile fields which give it
> acquire and release semantics.
That's true for the implementation. But the spec doesn't
say anything about consistency properties spanning multiple
queues. We've discussed whether we should add some. Doing
so hits several gray areas though, that we'd have to resolve
More information about the Concurrency-interest