Here's what we have now.
public static SingletonObject getInstance() {
if (instance == null) {
synchronized (SingletonObject.class) {
// might have been preempted just after first check
// but before the synchronized statement was executed
if (instance == null) {
instance = new SingletonObject();
}
}
}
return instance;
}

0 comments:
Post a Comment