Re: Why SynchronousQueue.TransferQueue#clean() not clean the last node

Martin Buchholz via Concurrency-interest <[email protected]> Sun, 16 Aug 2020 19:23:29 -0700
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CA+kOe09n+8apcz=zsMJMkCxzhf_Ftx2i=v8uWpuGAc5iLdB9eg@mail.gmail.com>
When a thread wants to enqueue a new element at the end, it finds the
last Node (the unique one whose next is null) and tries to CAS next to
a new Node containing the new element.  If the CAS succeeds, it must
have atomically enqueued the new element.

On Sun, Aug 16, 2020 at 7:14 PM Liu <[email protected]> wrote:
>
>
> I try to understand what you guys are saying.
>
> Firstly,    A -> B -> C(tail) -> null, and if C should be cleaned,
>  it should become A -> B(tail)  -> null. but there is No such atomic operation.
>
> Secondly, some threads may see A -> B  -> null and C(tail), and may append node
> after C which is wrong.
>
>
>
>
>
_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest