why does NSManagedObjectContext Queue execute on main thread?

后端 未结 1 569
野的像风
野的像风 2021-01-13 15:32

When I send a performBlock message to my MOC of type NSPrivateQueueConcurrencyType, like this:

[self.privateManagedObjectContext pe         


        
相关标签:
1条回答
  • 2021-01-13 16:13

    This optimization is possible because performBlockAndWait: executes the block synchronously, i.e. the method does not return until the block has finished. Therefore the block will not be executed in parallel with other operations on the main thread.

    (For the same reason, dispatch_sync(queue, ...) may execute a block on the main thread instead of a separate thread.)

    0 讨论(0)
提交回复
热议问题