看看这段代码:
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, nil), ^
{
NSLog(@"DISPATCH_QUEUE");//executed
//never goes further
dispatch_sync(dispatch_get_main_queue(), ^
{
NSLog(@"MAIN_QUEUE");
});
NSLog(@"END OF DISPATCH QUEUE");
});
我希望这段代码能像往常一样运行程序流,但它总是放入控制台字DISPATCH_QUEUE
,而且永远不会走得更远。程序刚刚停止。谁能解释为什么它会这样?幕后发生了什么让它停止?