void build(){
while(true){
Builder builder = new Builder();
...
}
}
class Builder{
private final Store store = null;
public Builder(){
store = Store.getInstance();
}
}
The 'Store' is implemented as a standard singleton class, as shown here: https://en.wikipedia.org/wiki/Singleton_pattern
I hope the Store object will be initialized only once and in the 'while' loop the same 'store' object will be created and returned inside the multiple "builder" objects due to the whole loop. Is this guaranteed? What about if defining "store" as a static variable of Builder?