可以参考我之前的总结 https://www.jianshu.com/p/991061eafe4d
- waitUntilDone 需要等 selector 执行完毕后 执行后面代码
- 自旋锁(OSSpinLock),优先级反转:高优先级一直在忙等导致低优先级无法获取完成任务
os_unfair_lock(iOS10开始支持)
OSSpinLock(优先级反转,自旋锁)
dispatch_semaphore
pthread_mutex
dispatch_queue(DISPATCH_QUEUE_SERIAL)
NSLock
NSCondition
pthread_mutex(recursive)
NSRecursiveLock(recursive)
NSConditionLock
@synchronized(mutex递归锁,内部生成obj对应的递归锁)