On Thu, 18 Feb 2021 01:08:30 GMT, Jaikiran Pai <j...@openjdk.org> wrote:

>> src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java line 171:
>> 
>>> 169: 
>>> 170:     public static ExtendedSocketOptions getInstance() {
>>> 171:         if (instance != null) {
>> 
>> May be it's worth to avoid reading `volatile` field twice?
>
> Hello @turbanoff, do you mean why read it twice - once here and once inside 
> the `synchronized` block?

Yes. Once here and once inside `synchronized` block.
Reading `volatile` fields cost _something_ on some architectures, so I think we 
could optimize it a bit.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2601

Reply via email to