Problem Statement
What does the lazy delegate do in Kotlin?
Explanation
The lazy delegate delays property initialization until the property is first accessed, then caches the computed value for subsequent accesses, useful for expensive operations you want to defer until needed. By default, lazy is thread-safe ensuring initialization happens only once even with concurrent access.
Use lazy for properties that are expensive to compute, might not be needed, or depend on state that isn't available during object construction. The initialization lambda runs only once, and the result is stored and returned for all future accesses.
You can customize thread safety with LazyThreadSafetyMode: SYNCHRONIZED for thread-safe default, PUBLICATION allowing multiple initializations but only one wins, or NONE for no synchronization when single-threaded.
