CoreData之performBlock 和 performBlockAndWait

兩個(gè)函數(shù)的區(qū)別是performBlock不會(huì)阻塞運(yùn)行的線程,相當(dāng)于異步操作,performBlockAndWait會(huì)阻塞運(yùn)行線程,相當(dāng)于同步操作

performBlock 和 performBlockAndWait 的區(qū)別:

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).

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 今天用了一下android sdk的traveView工具,真心感覺google好強(qiáng)大啊。 這個(gè)工具可以計(jì)算每個(gè)方...
    100斤閱讀 541評(píng)論 0 0
  • 每個(gè)人都有著自己的生活,他們生活在自己的世界里,踐行著在他們眼中存在于這個(gè)世界的意義。 也許我們沒有理由去批判生...
    生命中的第五個(gè)季節(jié)life閱讀 352評(píng)論 0 3
  • 他是普通上班族,一個(gè)早八晚五的小白領(lǐng)。他是獨(dú)立品牌創(chuàng)始人,公司早已占領(lǐng)國際市場。對(duì)于別人來說,這不過是一場灰姑娘遇...
    我是小阿旭吖閱讀 417評(píng)論 0 0
  • 是什么時(shí)候?qū)x(yuan)頭渚(zhu)感興趣的呢?大概是從發(fā)現(xiàn)一個(gè)地名的三個(gè)字居然有兩個(gè)字不認(rèn)識(shí)的時(shí)候吧!但它已...
    逸秋宏閱讀 636評(píng)論 0 0

友情鏈接更多精彩內(nèi)容