我有一个关于线程的问题。我有一个显示两个图像的视图(对手的横幅)。我已经阅读了可以一起运行的线程组。
我现在的方式是:
- (void) setBanners{
[getBanner:@"TeamA"];
[getBanner:@"TeamB"];
}
- getBanner:(NSString *team){
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^(void){
..Goto server and get logo
}
}
所以我的问题是,这是否与对线程进行分组的方式相同,或者当一个完成时是否会调用两个团队的方法?通过分组,它看起来像这样:
- setBanner{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, queue, ^{
get logo team a
});
dispatch_group_async(group, queue, ^{
get logo team a
});
}