From 4e8cdc7c960ce991fce94cfb0143466e9526a6a6 Mon Sep 17 00:00:00 2001 From: Bharath Kalyan S Date: Sat, 11 Feb 2023 22:31:32 +0530 Subject: [PATCH] fix: Issue #2459 fixed (#2467) --- .../iluwatar/singleton/ThreadSafeLazyLoadedIvoryTower.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeLazyLoadedIvoryTower.java b/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeLazyLoadedIvoryTower.java index 58d6e53b9..fcafba361 100644 --- a/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeLazyLoadedIvoryTower.java +++ b/singleton/src/main/java/com/iluwatar/singleton/ThreadSafeLazyLoadedIvoryTower.java @@ -44,13 +44,9 @@ public final class ThreadSafeLazyLoadedIvoryTower { * The instance doesn't get created until the method is called for the first time. */ public static synchronized ThreadSafeLazyLoadedIvoryTower getInstance() { - if (instance == null) { - synchronized (ThreadSafeLazyLoadedIvoryTower.class) { - if (instance == null) { + if (instance == null) { instance = new ThreadSafeLazyLoadedIvoryTower(); - } } - } return instance; } }