CoreData之performBlock 和 performBlockAndWait

两个函数的区别是performBlock不会阻塞运行的线程,相当于异步操作,performBlockAndWait会阻塞运行线程,相当于同步操作

performBlock 和 performBlockAndWait 的区别:

performBlock : Asynchronously performs a given block on the receiver’s queue.
performBlockAndWait : Synchronously performs a given block on the receiver’s queue.

stack overflow解释如下:

The main point is that when you call any *performBlock **or GCD function, you should not expect it to run on any particular thread (except something tied to the main thread) because queues are not threads, and only the main queue will run blocks on a specific thread.

When calling the core data performBlockAndWait the block will execute in the calling thread (but will be appropriately synchronized with everything submitted to the queue).

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 今天用了一下android sdk的traveView工具,真心感觉google好强大啊。 这个工具可以计算每个方...
    100斤阅读 530评论 0 0
  • 每个人都有着自己的生活,他们生活在自己的世界里,践行着在他们眼中存在于这个世界的意义。 也许我们没有理由去批判生...
    生命中的第五个季节life阅读 340评论 0 3
  • 他是普通上班族,一个早八晚五的小白领。他是独立品牌创始人,公司早已占领国际市场。对于别人来说,这不过是一场灰姑娘遇...
    我是小阿旭吖阅读 414评论 0 0
  • 是什么时候对鼋(yuan)头渚(zhu)感兴趣的呢?大概是从发现一个地名的三个字居然有两个字不认识的时候吧!但它已...
    逸秋宏阅读 625评论 0 0

友情链接更多精彩内容