单例模式学习草稿
package com.sise.case1;//单例模式 1.私有的静态的实例对象 private static instance//// 2.私有的构造函数(保证在该类外部,无法通过new的方式来创建对象实例) private Singleton(){}//// 3.公有的、静态的、访问该实例对象的方法 public static Singleton getInstance(){}public class TestSingleton { public static void main(String[] args) { //懒汉/** LazySingleton instance1 = LazySingleton.getInstance(); System.out.println(instance1); LazySingleton instance2 = LazySingleton.getInstance(); System.out.println(instance2); System.out.println(instance1==instance2);**/ new Thread(){ @Override public void run() { LazySingleton instance3 = LazySingleton.getInstance(); System.out