I wrote a below Singleton class. I am not sure whether this is thread safe singleton class or not?
protected static DataTask instance;
protected DataTask() {
// some code here
}
public static synchronized void setup() {
if (instance == null) {
DataTask setupFully = new DataTask();
instance = setupFully;
}
}
public static DataTask getInstance() {
if (instance == null) {
setup();
}
return instance;
}