I was under the impression that the double-check locking in Java has been phased out because the value visible in the first (unlocked) check as its seen from the CPU executing the current thread might be stale in the cache and not updated so you might get false negatives/positives if you check without the lock, and might never make it past the unlocked check when you should. I believe it still works if the var in the unlocked check is volatile but in that case the cache is getting flushed all the time with each check anyway, and might not present a gain compared to just locking and checking. Is this wrong? I had noticed these checks in the patch too.
On Mon, Nov 5, 2012 at 10:40 PM, Maja Kabiljo (JIRA) <[email protected]>wrote: > Maja Kabiljo created GIRAPH-412: > ----------------------------------- > > Summary: Checkstyle error from Giraph-403 > Key: GIRAPH-412 > URL: https://issues.apache.org/jira/browse/GIRAPH-412 > Project: Giraph > Issue Type: Bug > Reporter: Maja Kabiljo > Attachments: GIRAPH-412.patch > > I didn't try to run mvn verify before committing GIRAPH-403. It complained > about: > "The double-checked locking idiom is broken and should be avoided." > The reason why double-locking is bad doesn't apply here - it applies to > cases where we actually use the value of a variable which we are creating > in this way. > > -- > This message is automatically generated by JIRA. > If you think it was sent incorrectly, please contact your JIRA > administrators > For more information on JIRA, see: http://www.atlassian.com/software/jira >
