两个队列的背后很有可能是一个线程。在使用dispatch_get_current_queue来判断是否当前线程返回的可能不是你想要的结果。
if (dispatch_get_current_queue() == queue) {
block();
} else {
dispatch_sync(queue, block);
}
特别这种代码,dispatch_sync到一个队列就锁死了。
两个队列的背后很有可能是一个线程。在使用dispatch_get_current_queue来判断是否当前线程返回的可能不是你想要的结果。
if (dispatch_get_current_queue() == queue) {
block();
} else {
dispatch_sync(queue, block);
}
特别这种代码,dispatch_sync到一个队列就锁死了。
本文标题:为什么dispatch_get_current_queue被废弃
本文链接:https://www.haomeiwen.com/subject/widqcftx.html
网友评论