Skip to content

Singleton

1
2
3
4
5
6
7
8
9
public class Singleton {  
    private static class SingletonHolder {  
        private static final Singleton INSTANCE = new Singleton(); 
    }  
    private Singleton (){}  
    public static final Singleton getInstance() {  
        return SingletonHolder.INSTANCE; 
    }  
}

Multi-thread

1