这个静态类实现了什么样的模式?

Ale*_*dro 0 java design-patterns

package com.mycontainer;

public class MyContainer {
    private static ContainerConfig cConfig;

    private MyContainer() {

    }

    public static ContainerConfig getConfiguration() {      
        if (cConfig == null)            
            cConfig = new ContainerConfig();        
        return cConfig;
    }

}
Run Code Online (Sandbox Code Playgroud)

Abd*_*aly 6

它可能是Singleton模式:http://en.wikipedia.org/wiki/Singleton_pattern#Implementation

  • 它不是一个完整或正确的单例实现.它更像是Singleton-FAIL模式. (3认同)