On Tue, 23 Feb 2021 16:59:45 GMT, liach <github.com+7806504+li...@openjdk.org> wrote:
>>>This shouldn't be a problem. >> >> What do you mean by "this"? Double racy read? >> There are 2 separate reads of fields. First can return non-null value, while >> second still can get `null` > >> There are 2 separate reads of fields. First can return non-null value, while >> second still can get null > > Can this really happen? If this `version` field has been updated, its value > is definitely no longer `null`. And before the second field read the field is > always set to a non-null value on the current thread. I fail to understand > why the second read can still yield a null given the fact that the current > thread has updated it to a non-null value and other threads may have updated > it to a non-null value. I'm not really a JMM mastermind, but I know that @shipilev knows a thing or two about it :) See https://shipilev.net/blog/2016/close-encounters-of-jmm-kind/#wishful-benign-is-resilient ------------- PR: https://git.openjdk.java.net/jdk/pull/2691