0
Hello, What are the risks of error when using the Singleton practice in java? I am using the following:
private Os mInstance = null;
private int numeroOs, updateServer;
Context context;
public synchronized Os getInstance(Context c, int numeroOs) {
context = c;
if (mInstance == null) {
mInstance = new Os(context.getApplicationContext(), numeroOs);
}
return mInstance;
}
protected Os(Context context, int numeroOs) {
this.numeroOs = numeroOs;
this.context = context;
}
When should I instantiate the class Os (for example) to set the input parameters "context and numeroOs"? and if it is not instantiated what happens?
Risk? Wrong modeling is a high risk
– Jefferson Quesado
I guess just the fact that you’re wearing it and not knowing the risk is a big enough risk.
– user28595
This case of yours wouldn’t be a multiton?
– Jefferson Quesado