logo       

Re: Is enq(Node node) safe?: msg#00013

java.jsr.166-concurrency

Subject: Re: Is enq(Node node) safe?

Hu, Jinsong wrote:
My original posting does not assume that both threads need to successfully
compareAndSetHead at the same time, they do have orders, one at a time, the
point is, the first succeeded thread was forced to sleep after it
successfully compareAndSetHead, since the first thread already finished
this, the second thread should not fail on compareAndSetHead.

No. compareAndSetHead(h) expands to a compareAndSet(null, h). Only
the first thread can succeed in CAS'ing head to non-null. The other might spin for a while until the successful one wakes up, but since this
is a race in one-time initialization code, the potential for an unbounded spin is not worth specially handling. (Preliminary versions
of this class had some spin control here, but in testing even on big
multiprocessors, it was found not to have any effect so was simplified
away.)

-Doug


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise