Possible atomicity violations when composing concurrent collections operations
Yu Lin
yu.lin.86 at gmail.com
Thu Aug 2 14:35:09 PDT 2012
2012/8/2 Phil Race <philip.race at oracle.com>:
> On 8/2/2012 11:52 AM, Yu Lin wrote:
>
> I haven't looked at the rest but I'll comment on that one.
> This is deliberate. The tradeoff is all uses being synchronized versus
> the small chance that two threads try to create this map at the same
> time, which really doesn't matter. Its just a tiny bit of lost work.
> We could have a debate about how uncontended synchronization
> is cheap but adding it somewhat defeats the purpose of using
> ConcurrentHashMap. Also if there are two threads active here,
> meriting the synchronization then the lock probably is contended ..
>
> Also I am not sure how your patch below would work.
> Synchronizing on (null) isn't likely to fix anything.
> Instead you just introduced a NullPointerException.
>
Thanks for the comments, Phil.
I see your point (I agree that the synchronization should be on "this"
object if it's needed).
> Finally jdk8-dev is probably the "main" list these days.
>
Should I post this issue to the mailing list of jdk8-dev?
Yu
More information about the jdk7u-dev
mailing list