Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Creating a singleton
public class DbManager {
static volatile DbManager singleton = null;
private DbManager() {
}
public static DbManager getInstance() {
if (singleton == null) {
synchronized (DbManager.class) {
if (singleton == null)
singleton = new DbManager();
}
}
return singleton;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment