帮你理解多线程
时间:2014-05-07 21:37:21
收藏:0
阅读:305
static BOOL flag=NO;
dispatch_queue_t myQueue=dispatch_queue_create("identifier", NULL);
dispatch_async(myQueue, ^{
for (int i=0; i<10; i++) {
NSLog(@"%d",i);
}
flag=YES;
});
NSLog(@"before");
while (!flag){
NSLog(@"after");
}
NSLog(@"after2");
return;
dispatch_queue_t myQueue=dispatch_queue_create("identifier", NULL);
dispatch_async(myQueue, ^{
for (int i=0; i<10; i++) {
NSLog(@"%d",i);
}
flag=YES;
});
NSLog(@"before");
while (!flag){
NSLog(@"after");
}
NSLog(@"after2");
return;
评论(0)