#應(yīng)用場(chǎng)景:
重量級(jí)的對(duì)象,不需要多個(gè)實(shí)例,比如線程池,數(shù)據(jù)庫(kù)連接池。
###1.懶漢式:延遲加載,只有在使用的時(shí)候才開(kāi)始實(shí)例化。
1)線程安全問(wèn)題
2)double check
3)
```
public static LazySingletion getInstance(){
? ? if(instance==null){
? ? ? ? sysnchroinzed(LazySingleton.class){
?????????????if(instance==null){
? ? ? ? ? ? instance=new LazySinleton();
? ? ? ?????}
????????}
????}
return instance;
}
```