mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-16 14:23:05 +00:00
removed the lazy instantiation from singleton to avoid threading
problems.
This commit is contained in:
@@ -7,14 +7,11 @@ package com.iluwatar;
|
|||||||
*/
|
*/
|
||||||
public class IvoryTower {
|
public class IvoryTower {
|
||||||
|
|
||||||
private static IvoryTower instance;
|
private static IvoryTower instance = new IvoryTower();
|
||||||
|
|
||||||
private IvoryTower() {}
|
private IvoryTower() {}
|
||||||
|
|
||||||
public static IvoryTower getInstance() {
|
public static IvoryTower getInstance() {
|
||||||
if(instance == null){
|
|
||||||
instance = new IvoryTower();
|
|
||||||
}
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user