Skip to content

Commit d6aed14

Browse files
committed
removed the lazy instantiation from singleton to avoid threading
problems.
1 parent 2552d1b commit d6aed14

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

singleton/src/main/java/com/iluwatar/IvoryTower.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
*/
88
public class IvoryTower {
99

10-
private static IvoryTower instance;
10+
private static IvoryTower instance = new IvoryTower();
1111

1212
private IvoryTower() {}
1313

1414
public static IvoryTower getInstance() {
15-
if(instance == null){
16-
instance = new IvoryTower();
17-
}
1815
return instance;
1916
}
2017
}

0 commit comments

Comments
 (0)