Multithreading two in Core data

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.