I am completely puzzled by this code because I know the intent is to have thread safe access to a single instance of the object DataService but I don't know if it achieves that.
It just stands out to me Caller class:
protected final DataService dataService = DataService.getInstance();
Singleton class method:
private static DataService dService=null;
public static synchronized DataService getInstance() {
if (dService == null)
dService = new DataService();
return dService;
}
What is achieved by using protected final modifiers in the calling class?
Are they necessary and a good practice?