单例模式(Singleton)
枚举单例
public enum Singleton {
INSTANCE;
public void m() {}
public static void main(String[] args) {
for(int i = 0; i<100; i++) {
new Thread(()->{
System.out.println(Singleton.INSTANCE.hashCode());
}).start();
}
}
}
网友评论