I have read The "Double-Checked Locking is Broken" Declaration. But I wonder if i create the object by a function, will that be ok?
class Foo {
private Helper helper = null;
public Helper getHelper() {
if (helper == null)
synchronized(this) {
if (helper == null)
helper = createHelper();
}
return helper;
}
private Helper createHelper() {
return new Helper();
}
// other functions and members...
}