53

OC中atomic属性如何保证线程安全 - 简书

 6 years ago
source link: https://www.jianshu.com/p/574f2223ccb0?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
原子(atom)指化学反应不可再分的基本微粒,原子在化学反应中不可分割,而在程序中一般是指不可被打断或者干扰的操作。 序言 OC中的属性可以修饰成nonatomic和atomic,即原子和非原子属性。atomic属性设计的出发点是保证多线程下使用属性的安全性,由于看不到编译器对于该语法的实际处理,对于内部的实现,流行的观点是这样的:通过对属性的set/get方法加锁实现读写的互斥来保证线程安...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK