[concurrency-interest] Quick question on ConcurrentLinkedQueue

Joseph Seigh jseigh_cp00 at xemaps.com
Mon Apr 9 06:31:24 EDT 2007

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.

Joe Seigh

More information about the Concurrency-interest mailing list