Files
java-design-patterns/lazy-loading/src/main/java/com/iluwatar/lazyloading/HolderNaive.java
T
2015-05-31 11:55:18 +03:00

24 lines
364 B
Java

package com.iluwatar.lazyloading;
/**
*
* Simple implementation of the lazy loading idiom.
* However, this is not thread safe.
*
*/
public class HolderNaive {
private Heavy heavy;
public HolderNaive() {
System.out.println("HolderNaive created");
}
public Heavy getHeavy() {
if (heavy == null) {
heavy = new Heavy();
}
return heavy;
}
}