当前位置:网站首页>Singleton DCL (double check the lock) full han mode and the hungry
Singleton DCL (double check the lock) full han mode and the hungry
2022-08-09 06:33:00 【The strongest disciple in history】
public class Test29 {public static void main(String[] args) {SingleObject singleObject = SingleObject.getSingleObject();}}//Singleton hungry modeclass SingleObject2{private static volatile SingleObject2 singleObject = new SingleObject2();private SingleObject2 (){}public static SingleObject2 getSingleObject(){return singleObject;}}//Singleton full Chinese modeclass SingleObject{private static volatile SingleObject singleObject;private SingleObject (){}//double Check lockpublic static SingleObject getSingleObject(){if(singleObject == null){synchronized (SingleObject.class){if(singleObject == null){singleObject = new SingleObject();}}}return singleObject;}}
边栏推荐
猜你喜欢
[GO], arrays and slices
Output method of list string print(*a) print(““.join(str(c) for c in a) )
DevNet: Deviation Aware Networkfor Lane Detection
6 states of a thread
C language implements sequential stack and chain queue
Introduction of convenient functions and convenient shortcut keys of vs tomato assistant
变压器的工作原理(图解,原理图讲解,一看就懂)
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS重大开销和将disab补充道
leetcode 之 零移位
Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial
随机推荐
golang zip aes base64
shardingsphere数据分片配置项说明和示例
ZIP压缩包文件删除密码的方法
How to find package information and pin definitions for NXP S32K1xx series microcontrollers
Integer 线程安全的
Service
详解C语言中的wait()函数和waitpid()函数
Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine
运放-运算放大器经典应用电路大全-应用电路大全
The singleton pattern
CMake中INSTALL_RPATH与BUILD_RPATH问题
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS重大开销和将disab补充道
6 states of a thread
力扣刷题180
Word文件的只读模式没有密码怎么退出?
leetcode 之 70 爬楼梯问题 (斐波那契数)
Simple Factory Pattern
db.sqlite3 has no "as Data Source" workaround
Silently start over, the first page is also a new page
字节跳动面试题之镜像二叉树2020