You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
325 B
13 lines
325 B
3 years ago
|
## 介绍
|
||
|
单例模式主要解决的是,一个全局使用的类频繁的创建和消费,从而提升整体的代码性能
|
||
|
+ 数据库连接池
|
||
|
+ spring bean单例
|
||
|
+ 代码中的全局属性保存
|
||
|
## 代码例子
|
||
|
|
||
|
内部类单例
|
||
|
![[Snipaste_2023-02-12_13-54-33.png]]
|
||
|
|
||
|
|
||
|
枚举单例
|
||
|
![[Snipaste_2023-02-12_13-54-57.png]]
|