| private static final AtomicReference<List<ServiceLoader.Provider<MemoryManager>>> CACHE Cache the service loader result to reduce cost of repeated calls.
However, also place the cached loader field in a dedicated class, so the service loading is performed lazily,
on class initialisation, when (and if) needed.
ServiceLoader objects are not actually thread-safe, so instead of caching the loader itself, we
cache its result.
This becomes a bit more complicated by the fact that the service-loader stream is lazy.
|