我对使用dispatch_once
非常困惑。以下两个版本的代码可以给出相同的结果。使用dispatch_once
时有什么不同?dispatch_once用法用于异步处理
版本1
static dispatch_queue_t downloadQueue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
downloadQueue = dispatch_queue_create("temp", 0);
});
2版
static dispatch_queue_t downloadQueue;
downloadQueue = dispatch_queue_create("dryapp", 0);