---
title: "23种设计模式之单例模式（Singleton）"
author: "lynnwoo"
date: "2010-10-22T11:13:42Z"
tags: []
categories: ["编程语言"]
slug: "23-singleton"
draft: false
lastmod: "2010-10-22T11:41:14Z"
id: 791306
url: "https://lynnwoo.iteye.com/blog/791306"
---

保证一个类仅有一个实例，并提供一个访问它的全局访问点


![](http://dl.iteye.com/upload/attachment/335567/e3a4abd0-5e59-3ede-a3d3-a9b1ccb0720e.gif)


```java

package org.example.patterns.singletonPattern;
/**
 * @author LY
 * @version 创建时间：Oct 22, 2010 11:14:20 AM
 * 类说明 ： 单例模式
 */
public class Singleton {
	private static Singleton instance = null;
	
	public static synchronized Singleton getInstance (){
		return (instance == null) ? new Singleton(): instance;
	}
}


```