I have come across some code, where the developer is constantly checking if the singleton is null twice with a nested if - like in the code below:
private static processManager singleton = null;
...
public synchronized static processManager getInsatnce() throws Exception {
if(singleton == null) {
if(singleton == null){
singleton = new processManager();
}
}
return singleton
}
I cannot see any reason why this might be, but there are numerous instances in the code, so thought there might be a reason?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…