Thread-safe Singleton class

New Singleton class name has renamed to ThreadSafeLazyLoadedIvoryTower
and called it from App.java
This commit is contained in:
Sujan Reddy Annem
2014-10-13 22:15:45 -07:00
parent cffe592c9c
commit 5687976a91
3 changed files with 32 additions and 20 deletions

@ -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);
}
}