当前位置:网站首页>[JUC supplementary] atomic class, unsafe
[JUC supplementary] atomic class, unsafe
2022-06-11 11:48:00 【Mr. Mingmu】
reference:https://zhuanlan.zhihu.com/p/115345089
atomic Class provides many classes , These classes perform atomic operations on different data types 

example

Source code analysis
The bottom is unsafe Class cas operation , and Unsafe The bottom layer is actually calling C Code (native Keyword modification ),C Code calls assembly , Finally, a CPU Instructions cmpxchg, To complete the operation . That's why CAS It's atomic , because It's a CPU Instructions , Will not be interrupted .

Unsafe
Now that it's up there unsafe Here to learn more
obtain unsafe:
Because its constructor is private, it cannot new
Earlier versions use reflection to get the internally created theUnsafe:
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);// Set up private by public
Unsafe unsafe = (Unsafe) f.get(null);
The latest version is more open and offers get Go straight back to 
except cas What other operations are relatively low-level ?
Locksupport Of park And unpark stay unsafe The underlying implementation of 
Operate on memory , It's a memory level operation , You can specify the memory address and release , Very low level 
边栏推荐
- Is it safe for Xiaobai to open an account directly on the flush?
- Where is it safer to open an account for soda ash futures? How is the deposit calculated?
- Bark – 自己给自己的 iPhone 发推送提醒 – 最简单的推送提醒服务,开源免费
- WordPress重新生成特色图像插件:Regenerate Thumbnails
- MYCAT sub database and sub table
- web开发选型,web开发毕业谁
- 发布WordPress数据库缓存插件:DB Cache Reloaded 3.1
- js合并两个对象(面试题)
- C# 读取txt文件生成Word文档
- Lifeifei: I am more like a scientist in physics than an engineer
猜你喜欢

How does Sister Feng change to ice?

吊打面试官,涨姿势

Apple mobileone: the mobile terminal only needs 1ms of high-performance backbone

Zhejiang University and Microsoft Asia Research Institute released a new method of video recognition, which can recognize video frame by frame without data marking, or can be used for sign language tr

Adapter mode -- can you talk well?

msf cs openssl流量加密

JS 加法乘法错误解决 number-precision

C# 在PDF文档中应用多种不同字体

读取geo表达矩阵

Jest unit test description config json
随机推荐
MSF CS OpenSSL traffic encryption
Gerber文件在PCB制造中的作用
WordPress regenerate featured image plugin: regenerate thumbnails
[C language] anonymous/unnamed struct & Union
Elk - elastalert largest pit
web开发选型,web开发毕业谁
Node连接MySql数据库写模糊查询接口
Network protocol of yyds dry goods inventory: datagram socket for detailed explanation of socket protocol
NFT digital collection app system construction
在畢設中學習03
AGCO AI frontier promotion (6.11)
How to understand CPU load
推荐几款Gravatar头像缓存插件
【Go】Gin源码解读
NFT digital collection system platform construction
How to form a good habit? By perseverance? By determination? None of them!
WordPress站内链接修改插件:Velvet Blues Update URLs
Streaking? Baa!
[file upload vulnerability 05] server suffix detection and bypass experiment (based on upload-labs-3 shooting range)
[issue 30] shopee golang development experience