mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-12 00:13:56 +00:00
Thread-safe Singleton class
New Singleton class name has renamed to ThreadSafeLazyLoadedIvoryTower and called it from App.java
This commit is contained in:
1 parent
cffe592c9c
commit
5687976a91
3 files changed
+32
-20
No files matched your search
@@ -1,10 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Singleton pattern ensures that the class (IvoryTower) can have only one
|
||||
* existing instance and provides global access to that instance.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
@@ -15,5 +15,12 @@ public class App {
|
||||
System.out.println("ivoryTower1=" + ivoryTower1);
|
||||
System.out.println("ivoryTower2=" + ivoryTower2);
|
||||
|
||||
ThreadSafeLazyLoadedIvoryTower threadSafeIvoryTower1 = ThreadSafeLazyLoadedIvoryTower
|
||||
.getInstance();
|
||||
ThreadSafeLazyLoadedIvoryTower threadSafeIvoryTower2 = ThreadSafeLazyLoadedIvoryTower
|
||||
.getInstance();
|
||||
System.out.println("threadSafeIvoryTower1=" + threadSafeIvoryTower1);
|
||||
System.out.println("threadSafeIvoryTower2=" + threadSafeIvoryTower2);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user