Solution: Mutable lazy delegate
This solution lacks thread safety. The simplest way to make it thread safe is to use a
synchronized
block. A more efficient solution is to use theAtomicReference
andcompareAndSet
functions.
This solution lacks thread safety. The simplest way to make it thread safe is to use a
synchronized
block. A more efficient solution is to use theAtomicReference
andcompareAndSet
functions.