mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-16 00:59:02 +00:00
29 lines
439 B
Java
29 lines
439 B
Java
package com.iluwatar.lazy.loading;
|
|
|
|
/**
|
|
*
|
|
* Simple implementation of the lazy loading idiom. However, this is not thread safe.
|
|
*
|
|
*/
|
|
public class HolderNaive {
|
|
|
|
private Heavy heavy;
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public HolderNaive() {
|
|
System.out.println("HolderNaive created");
|
|
}
|
|
|
|
/**
|
|
* Get heavy object
|
|
*/
|
|
public Heavy getHeavy() {
|
|
if (heavy == null) {
|
|
heavy = new Heavy();
|
|
}
|
|
return heavy;
|
|
}
|
|
}
|