当前位置:网站首页>The difference between the lazy mode of singleton mode and the evil mode
The difference between the lazy mode of singleton mode and the evil mode
2022-07-01 16:47:00 【Fried tomatoes with duck eggs】
The lazy type is , Only when using this use case , Then instantiate it , So be more efficient .
public class SingletonLH {
private static SingletonLH instance;
private SingletonLH(){};
public static SingletonLH getInstance(){
if (instance==null){
instance=new SingletonLH();
}
return instance;
}
public static void main(String[] args) {
SingletonLH instance = SingletonLH.getInstance();
System.out.println(instance);
}
}
Hungry Han style is the program as soon as it starts , Just instantiate him , When he is used, the time of re instance is saved , So the speed and response are fast . This is the difference between the two
public class SingletonEH {
private static SingletonEH instance =new SingletonEH();
private SingletonEH(){};
public static SingletonEH getInstance(){
System.out.println("instance:"+instance);
System.out.println(" Load hungry Chinese style ");
return instance;
}
public static void main(String[] args) {
SingletonEH instance = SingletonEH.getInstance();
System.out.println(instance);
}
}
The two biggest differences are that one is instantiation at the beginning , One is to wait until it is used
边栏推荐
- Submission lottery - light application server essay solicitation activity (may) award announcement
- How to cancel automatic search and install device drivers for laptops
- Is the securities account given by the head teacher of goucai school safe? Can I open an account?
- Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...
- 数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
- Advantages, values and risks of chain games compared with traditional games
- Installation and use of sqoop
- PR basic clip operation / video export operation
- Origin2018 installation and use (sorting)
- VMware virtual machine failed during startup: VMware Workstation is incompatible with hyper-v
猜你喜欢

Tutorial on the principle and application of database system (003) -- MySQL installation and configuration: manually configure MySQL (Windows Environment)

Redis6.0 新功能

【观察】数字化时代的咨询往何处走?软通咨询的思与行

How to solve the problem that the battery icon of notebook computer does not display

EndeavourOS移动硬盘安装

Tutorial on principles and applications of database system (004) -- MySQL installation and configuration: resetting MySQL login password (Windows Environment)

Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022

【Hot100】20. Valid parentheses

想做软件测试的女孩子看这里

广东用电量大跌,说明高新技术产业替代高能耗产业已取得初步成果
随机推荐
The sharp drop in electricity consumption in Guangdong shows that the substitution of high-tech industries for high-energy consumption industries has achieved preliminary results
Tutorial on the principle and application of database system (005) -- Yum offline installation of MySQL 5.7 (Linux Environment)
想做软件测试的女孩子看这里
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Rhcsa Road
Sword finger offer II 015 All modifiers in the string
Dataframe gets the number of words in the string
Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)
How to use MySQL language for row and column devices?
FPN网络详解
Apple's self-developed baseband chip failed again, which shows Huawei Hisilicon's technological leadership
[JetsonNano] [教程] [入门系列] [三] 搭建TensorFlow环境
Sweden announced its decision to exclude Huawei 5g equipment, but Huawei has successfully found a new way out
Endeavouros mobile hard disk installation
P2592 [ZJOI2008]生日聚会(dp)
Tutorial on principles and applications of database system (004) -- MySQL installation and configuration: resetting MySQL login password (Windows Environment)
VMware virtual machine failed during startup: VMware Workstation is incompatible with hyper-v
What are the differences between PHP and DW
Detailed explanation of activity life cycle and startup mode