mangotv / ik-analyzer

Automatically exported from code.google.com/p/ik-analyzer
1 stars 0 forks source link

java double lock check problem #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
there is some method use 'double lock check' to to get Singleton object,
like:
public static Dictionary initial(Configuration cfg){
        if(singleton == null){
            synchronized(Dictionary.class){
                if(singleton == null){
                    singleton = new Dictionary(cfg);
                    return singleton;
                }
            }
        }
        return singleton;
    }
but double lock check have been proved to be wrong in java, so please help to 
modify.
you can google: java double lock check, to get more details.

Original issue reported on code.google.com by hjq20021...@gmail.com on 30 May 2012 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by linliang...@gmail.com on 31 May 2012 at 9:42