diff --git a/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java b/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java index ed7d44705..ec23ba71b 100644 --- a/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java +++ b/singleton/src/main/java/com/iluwatar/singleton/IvoryTower.java @@ -27,22 +27,24 @@ package com.iluwatar.singleton; */ public final class IvoryTower { - /** - * Static to class instance of the class. - */ - private static final IvoryTower INSTANCE = new IvoryTower(); - /** * Private constructor so nobody can instantiate the class. */ private IvoryTower() {} + private static class IvoryTowerHolder { + /** + * Static to class instance of the class. + */ + private static final IvoryTower INSTANCE = new IvoryTower(); + } + /** * To be called by user to obtain instance of the class. * * @return instance of the singleton. */ public static IvoryTower getInstance() { - return INSTANCE; + return IvoryTowerHolder.INSTANCE; } }