Skip to content

Commit 600553e

Browse files
authored
Merge pull request iluwatar#583 from shaiktaj/patch-1
Updated ThreadSafeLazyLoadedivoryTower
2 parents 54d8ec9 + 24f2588 commit 600553e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ public final class ThreadSafeLazyLoadedIvoryTower {
3333

3434
private static ThreadSafeLazyLoadedIvoryTower instance;
3535

36-
private ThreadSafeLazyLoadedIvoryTower() {}
36+
private ThreadSafeLazyLoadedIvoryTower() {
37+
// to prevent instantiating by Reflection call
38+
if (instance != null) {
39+
throw new IllegalStateException("Already initialized.");
40+
}
41+
}
3742

3843
/**
3944
* The instance gets created only when it is called for first time. Lazy-loading

0 commit comments

Comments
 (0)