From d6aed142a7c07a3ab0e5723fe1a96e5b0796ebcd Mon Sep 17 00:00:00 2001 From: yusufaytas Date: Sun, 7 Sep 2014 21:21:24 +0100 Subject: [PATCH] removed the lazy instantiation from singleton to avoid threading problems. --- singleton/src/main/java/com/iluwatar/IvoryTower.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/singleton/src/main/java/com/iluwatar/IvoryTower.java b/singleton/src/main/java/com/iluwatar/IvoryTower.java index dadfc3548..113962eb8 100644 --- a/singleton/src/main/java/com/iluwatar/IvoryTower.java +++ b/singleton/src/main/java/com/iluwatar/IvoryTower.java @@ -7,14 +7,11 @@ package com.iluwatar; */ public class IvoryTower { - private static IvoryTower instance; + private static IvoryTower instance = new IvoryTower(); private IvoryTower() {} public static IvoryTower getInstance() { - if(instance == null){ - instance = new IvoryTower(); - } return instance; } }