标签:
NSOperationQueue *queue = [[NSOperationQueuealloc]init];
queue.maxConcurrentOperationCount = 2;
for (NSInteger i = 0 ; i <1000000;i ++ ) {
NSBlockOperation *operation = [NSBlockOperationblockOperationWithBlock:^{
sleep(1);
NSLog(@"%ld%@",i,[NSThread currentThread]);
}];
[queue addOperation:operation];
}
标签:
原文地址:http://www.cnblogs.com/zhujin/p/4274815.html