Possible atomicity violations when composing concurrent collections operations (original) (raw)
Yu Lin yu.lin.86 at gmail.com
Thu Aug 2 14:35:09 PDT 2012
- Previous message: Possible atomicity violations when composing concurrent collections operations
- Next message: Possible atomicity violations when composing concurrent collections operations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Possible atomicity violations when composing concurrent collections operations
- Next message: Possible atomicity violations when composing concurrent collections operations
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]