`
pouyang
  • 浏览: 313401 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Design Patterns 创建模式 之 Singleton

 
阅读更多
Design Patterns  创建模式 之 Singleton
1 Singleton
public class Single {
	private static Single single = null;
	private Single() {
		System.out.println("only one !");
	};
	public static Single getInstanceL() {
		synchronized (Single.class) {
			if (single == null) {
				single = new Single();
			}
		}
		return single;
	}
}
//-----------------------------------------------------
public class Single {
	private static Single single = new Single();
	private Single() {
		System.out.println("only one !");
	};
	public static Single getInstanceL() {
		return single;
	}
}




分享到:
评论

相关推荐

    Spring 5 Design Patterns

    Spring 5 Design Patterns第五版

    Programming.in.the.Large.with.Design.Patterns

    It starts with a general introduction to all types of programming patterns and goes on to describe 10 of the most popular design patterns in detail: Singleton, Iterator, Adapter, Decorator, State, ...

    Design.Patterns.Explained.Simply

    We've tried hard to avoid both of these categories with Design Patterns Explained Simply. This book is fast and simple way to get the idea behind each of the 29 popular design patterns. The book is ...

    《Java Design Patterns》高清完整英文PDF版

    Learn how to implement design patterns in Java: each pattern in Java Design Patterns is a complete implementation and the output is generated using Eclipse, making the code accessible to all....

    Apress.Pro.Design.Patterns.in.Swift

    Pro Design Patterns in Swift shows you how to harness the power and flexibility of Swift to apply the most important and enduring design patterns to your applications, taking your development ...

    Learning Python Design Patterns(PACKT,2013)

    Then you will move on to learn about two creational design patterns which are Singleton and Factory, and two structural patterns which are Facade and Proxy. Finally, the book also explains three ...

    Head First Design Patterns 英文版 Head First设计模式

    《Head First Design Patterns》共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式。前言先介绍《Head First Design Patterns》的用法;第1章到第11章陆续介绍的设计模式为Strategy、...

    Beginning SOLID Principles and Design Patterns for ASP.NET Developers.pdf

    ■Chapter 3: Creational Patterns: Singleton, Factory Method, and Prototype ■Chapter 4: Creational Patterns: Abstract Factory and Builder ■Chapter 5: Structural Patterns: Adapter, Bridge, Composite,...

    Modern C++ Design Generic Programming and Design Patterns Applied.pdf

    Patterns such as Visitor, Singleton, Command, and Factories Multi-method engines For each generic component, the book presents the fundamental problems and design options, and finally implements a ...

    Cocoa Design Patterns

    Patterns that empower, such as singleton, delegates, and the responder chain Patterns that hide complexity, including bundles, class clusters, proxies and forwarding, and controllers

    Design Patterns in Modern C++--2018

    Use creational patterns of builder, factories, prototype and singleton Implement structural patterns such as adapter, bridge, decorator, facade and more Work with the behavioral patterns such as ...

    Learning Python Design Patterns 2nd 2016第2版 无水印pdf 0分

    As you progress through the book, you will learn about Singleton patterns, Factory patterns, and Facade patterns in detail. After this, we'll look at how to control object access with proxy patterns....

    Design Patterns Elements of Reusable Object-Oriented Software

    • How Design Patterns Solve Design Problems • How to Select a Design Pattern • How to Use a Design Pattern A Case Study: Designing a Document Editor • Design Problems • Document Structure ...

    Head First Design Patterns

    第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、Abstract Factory、Factory Method、Singleton、Command、Adapter、Facade、Templat Method、Iterator、Composite、 State、Proxy。最后三章比较...

    Head First Design Patterns 高清英文版

    第1章到第11章陆续介绍的设计模式为Strategy、Observer、Decorator、Abstract Factory、Factory Method、Singleton,Command、Adapter、Facade、TemplateMethod、Iterator、Composite、State、Proxy。最后三章比较...

    Head First Design Patterns 英文原版

    Using the latest research in neurobiology, cognitive science, and learning theory, Head First Design Patterns will load patterns into your brain in a way that sticks. In a way that lets you put them ...

    Design-Patterns-Singleton:单例设计模式示例

    这是单例设计模式的基本示例。 您将在此仓库中找到两个示例。 首先是线程安全的单例,其次不是。...Thread 2 instance is : com.caslaner.designpatterns.singleton.service.CacheUnSynchronized@35c

    Data Structures And Algorithms With Object-Oriented Design Patterns In C Sharp.pdf

    the emerging object-oriented design patterns. Experienced object-oriented programmers find that certain ways of doing things work best and that these ways occur over and over again. The book shows how...

Global site tag (gtag.js) - Google Analytics