对于某些代码段,我想逐个执行,例如:
self.coreDataLock = [[NSRecursiveLock alloc] init];
// Snippet One
[self.coreDataLock lock];
[childContext performBlock:^{
// Do something
[self.coreDataLock unlock];
}];
// Snippet Two
[self.coreDataLock lock];
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
// Do something
[self.coreDataLock unlock];
});
但我无法锁定/解锁NSRecursiveLock交叉线程,如何弄明白?