Skip to content

Instantly share code, notes, and snippets.

@syaau
syaau / CollectionHolder.java
Created December 16, 2015 05:58
The Java Initializer Pattern for Thread Safe initialization from mutliple sources
/* An example class */
public class CollectionHolder {
private final List collection;
/* A private constructor to create a shadow instance for initization */
private CollectionHolder() {
collection = new ArrayList<>();
}
/* The public constructor */