单例模式(懒汉式)

package 单例模式.懒汉模式;

public class LazySingleton {
 private static LazySingleton m_instance;
 private LazySingleton(){}
 synchronized public LazySingleton getInstance()
 {
  if(m_instance == null)
  {
   m_instance = new LazySingleton();
  }
  return m_instance;
 }
}

你可能感兴趣的:(单例模式)