caching the result from a [n async] factory method iff it doesn’t throw

Does this get anywhere near your requirements? The behaviour falls somewhere between ExecutionAndPublication and PublicationOnly. While the initializer is in-flight all calls to Value will be handed the same task (which is cached temporarily but could subsequently succeed or fail); if the initializer succeeds then that completed task is cached permanently; if the initializer fails … Read more

Pattern for lazy thread-safe singleton instantiation in java

the lazy thread-safe singleton instantion is kinda not easy to understand to every coder No, it’s actually very, very easy: public class Singleton{ private final static Singleton instance = new Singleton(); private Singleton(){ … } public static Singleton getInstance(){ return instance; } } Better yet, make it an enum: public enum Singleton{ INSTANCE; private Singleton(){ … Read more