シングルトンパターンに二重チェックロックイディオムを使用する方が良いですか? それとも同期方式?
すなわち:
private static volatile ProcessManager singleton = null;
public static ProcessManager getInstance() throws Exception {
if (singleton == null) {
synchronized (MyClass.class) {
if (singleton == null) {
singleton = new ProcessManager();
}
}
}
return singleton;
}
また
private static processManager singleton = null;
public synchronized static processManager getInsatnce() throws Exception {
if(singleton == null) {
singleton = new processManager();
}
return singleton
}