Java 设计模式

2017-09-30  本文已影响0人  AlexSun1995

Factory Design

工厂模式有三种:简单工厂模式,工厂方法模式,抽象工厂模式

联想问题0

Singleton 设计模式

Singleton pattern restricts the instantiation of a class and ensures that only one instance of the class exists in the java virtual machine. The singleton class must provide a global access point to get the instance of the class. Singleton pattern is used for logging, drivers objects, caching and thread pool

很全的csdn博客
提炼出的关键问题:什么是懒汉模式,饿汉模式,为什么说饿汉模式是线程安全的,而懒汉模式需要同步机制才能保障线程安全?
如何使用threadLocal实现单例模式的线程安全?

联想问题1

上一篇 下一篇

猜你喜欢

热点阅读