Thread-safe Singleton class
New Singleton class name has renamed to ThreadSafeLazyLoadedIvoryTower and called it from App.java
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user