Skip to content

Instantly share code, notes, and snippets.

@code4lifevn
Created June 27, 2017 15:27
Show Gist options
  • Save code4lifevn/5a53f6a56ee068e8b7ea92a191af69df to your computer and use it in GitHub Desktop.
Save code4lifevn/5a53f6a56ee068e8b7ea92a191af69df to your computer and use it in GitHub Desktop.
Thread-safe Singleton
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