RFR: 8260366: ExtendedSocketOptions <clinit> can deadlock in some circumstances [v2]
    Andrey Turbanov 
    github.com+741251+turbanoff at openjdk.java.net
       
    Thu Feb 18 07:05:39 UTC 2021
    
    
  
On Thu, 18 Feb 2021 01:08:30 GMT, Jaikiran Pai <jpai at 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
    
    
More information about the net-dev
mailing list