第一部分:链接
- iOS 多线程:『pthread、NSThread』详尽总结
- .iOS 多线程:『GCD』详尽总结
- OS 多线程:『NSOperation、NSOperationQueue』详尽总结
- iOS 多线程:『RunLoop』详尽总结
- 关于performSelector:afterDelay:的一个坑及思考
第二部分:例子
1.NSThread
-(void)downloadImageOnSub{
[NSThread detachNewThreadSelector:@selector(downLoadImage) toTarget:self withObject:nil];
}
-(void)downLoadImage{
NSLog(@"Current Thread:%@", [NSThread currentThread]);
NSURL *imgUrl = [NSURL URLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=414435988,70382748&fm=15&gp=0.jpg"];
NSData *imgData = [NSData dataWithContentsOfURL:imgUrl];
UIImage *img = [UIImage imageWithData:imgData];
[self performSelectorOnMainThread:@selector(updateImageView:) withObject:img waitUntilDone:YES];
}
-(void)updateImageView:(UIImage*)img{
NSLog(