The use of multithreading in core data is not generally intended to improve performance and efficiency, but to enable the main thread to be unblocked, allowing the UI to continue to respond to user behavior while doing other data operations. When a fetch operation is performed, the Core data system automatically turns on multiple threads as needed to do the corresponding operation, so we do not increase the efficiency by adding multithreading ourselves, but simply to be able to free up the main line Cheng heavy data operations.
Description of the core data concurrency operation in Apple's official documentation:
Concurrency with Core Data:
1, use the Thread confinement to the support Concurrency.
2. Track changes on other Threads Using notifications
3. Fetch in the Background for UI responsiveness
4, saving in a Background Thread is Error-prone
5. If you Don ' t use Thread confinement
There is serveral situations in which performing operations with Core Data on a background thread or queue is beneficial, In particular if-want to ensure-your application ' s user interface remains responsive while Core Data is Undertak ing a long-running task. If you don't perform concurrent operations with Core Data, however, and you need to take considerable care this object graphs do Not get to an inconsistent (inconsistent) state.
If you choose to use concurrency with Core Data, you also need to consider the application environment. For the most part, AppKit and UIKit is not thread safe; In particular, on OS X Cocoa bindings and controllers is not thread safe-if is using these technologies, MULTI-THR Eading may complex.
Multithreading two in Core data