Thread-safe cache of one object in java
google collections actually supplies just the thing for just this sort of thing: Supplier Your code would be something like: private Supplier<List<String>> supplier = new Supplier<List<String>>(){ public List<String> get(){ return loadCountryList(); } }; // volatile reference so that changes are published correctly see invalidate() private volatile Supplier<List<String>> memorized = Suppliers.memoize(supplier); public List<String> list(){ return memorized.get(); … Read more