Created
June 27, 2017 15:27
-
-
Save code4lifevn/5a53f6a56ee068e8b7ea92a191af69df to your computer and use it in GitHub Desktop.
Thread-safe Singleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppConfig { | |
private static AppConfig INSTANCE = null; | |
private Context context; | |
private AppConfig(Context context) { | |
this.context = context; | |
} | |
public static AppConfig get(Context context) { | |
if (INSTANCE == null) { | |
synchronized (AppConfig.class) { | |
if (INSTANCE == null) { | |
INSTANCE = new AppConfig(context); | |
} | |
} | |
} | |
return INSTANCE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment