Lazy Loading in Java - tarunchhabra/parakalo GitHub Wiki
lazy loading-
via static factory methods, lazy-load Singleton via Suppliers via @lazy in Spring via FetchType.LAZY in Hibernate
Lazy Loading using Java Supplier
-
the goal is to create a Lazy class that can be used for objects with a relatively long life expectancy and where there might be any number of calls (from zero to the millions) to a particular method.
-
We must also ensure that the class is thread safe.
-
Lastly, we want to have maximum performance for different threads calling the class many times.
When Are Lazy Appropriate to Use? Lazy is a good choice if we want to defer calculation to a later time and we do not want to repeat the calculation. For objects/Classes with a relatively long life expectancy and where there might be any number of calls.