---
title: "单例模式之懒汉模式"
author: "bigSeven"
date: "2015-12-05T17:09:09Z"
tags: ["Java设计模式", "单例模式", "懒汉模式"]
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2015-12-05T17:09:09Z"
id: 2262043
url: "https://bigseven.iteye.com/blog/2262043"
---

package mode;

 

/\**

 * 设计模式之懒汉模式

 * @author gaoq

 * @date 2015-12-5 下午5:04:15

 \*/

public class SingletoLazyMode {

 

private static volatile SingletoLazyMode singletoLazyMode = null;

 

/\*\*防止外部创建对象\*\*/

private SingletoLazyMode() {

 

}

 

public static SingletoLazyMode getInstance(){

if(null == singletoLazyMode){

singletoLazyMode = new SingletoLazyMode();

}

return singletoLazyMode;

}

 

public void test(){

System.out.println("hello，懒汉");

}

 

}