We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 54d8ec9 + 24f2588 commit 600553eCopy full SHA for 600553e
1 file changed
singleton/src/main/java/com/iluwatar/singleton/ThreadSafeLazyLoadedIvoryTower.java
@@ -33,7 +33,12 @@ public final class ThreadSafeLazyLoadedIvoryTower {
33
34
private static ThreadSafeLazyLoadedIvoryTower instance;
35
36
- private ThreadSafeLazyLoadedIvoryTower() {}
+ private ThreadSafeLazyLoadedIvoryTower() {
37
+ // to prevent instantiating by Reflection call
38
+ if (instance != null) {
39
+ throw new IllegalStateException("Already initialized.");
40
+ }
41
42
43
/**
44
* The instance gets created only when it is called for first time. Lazy-loading
0 commit comments