首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调度系统如何引起deadLock?ios

调度系统如何引起deadLock?ios
EN

Stack Overflow用户
提问于 2014-08-25 12:47:44
回答 1查看 196关注 0票数 0

apple说:调用此函数并针对当前队列将导致死锁!

但是这段代码很好用:

代码语言:javascript
复制
   dispatch_queue_t concurrentQueue = 

dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(concurrentQueue, ^{
                        __block UIImage *image = nil;
                        dispatch_sync(concurrentQueue, ^{ 
                        /* Download the image here sync downloading */
                        });

                        dispatch_sync(dispatch_get_main_queue(), ^{
                        /* Show the image to the user here on the main queue */
                        });
        });

尽管我用dispatch_sync下载了映像并将块发送到相同的队列中!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-25 14:05:33

文件说:

您不应该从正在计划传递给函数的同一个队列中执行的任务调用dispatch_sync或dispatch_sync_f函数。这对于保证死锁的串行队列尤其重要,但对于并发队列也应该避免。

因为dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)并发队列,所以它可能导致死锁,但并不总是如此。不管怎么说,这是苹果公司严格禁止的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25486325

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档