Files
java-design-patterns/singleton/src/main/java/com/iluwatar/ThreadSafeLazyLoadedIvoryTower.java
T
Sujan Reddy Annem 5687976a91 Thread-safe Singleton class
New Singleton class name has renamed to ThreadSafeLazyLoadedIvoryTower
and called it from App.java
2014-10-13 22:15:45 -07:00

24 lines
462 B
Java

package com.iluwatar;
/**
*
* Thread-safe Singleton class.
*
*/
public class ThreadSafeLazyLoadedIvoryTower {
private static ThreadSafeLazyLoadedIvoryTower instance = null;
public synchronized static ThreadSafeLazyLoadedIvoryTower getInstance() {
/*
* The instance gets created only when it is called for first time.
* Lazy-loading
*/
if (instance == null) {
instance = new ThreadSafeLazyLoadedIvoryTower();
}
return instance;
}
}