Threading is an extremely difficult subject. Very few developers get it right, and even those few still manage to make mistakes in this area. Threading is arguably one of the hardest concepts in computer science.
Threading with Core Data used to be extremely difficult to get right. Now with having only main queue and private queue contexts, it has gotten a lot simpler. It boils down to a simple Boolean decision. If you’re working with the UI, you should be using a main queue context. If you aren’t, then you should be using a private queue context.
However, even with this threading model you may encounter a situation when a lot of work needs to be done on the data in a short period of time. For those very rare instances, the Core Data framework has two APIs to handle bulk changes to the data structure. We discuss them in the next chapter.