第一部分:链接
- 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
iOS并发线程深度解析:Objective-C实践

本文深入探讨了iOS并发线程,包括pthread、NSThread、GCD、NSOperation、NSOperationQueue和RunLoop的详尽总结。此外,还通过实例展示了NSThread的UI更新、NSNotification的注册、NSRunLoop的运行模式以及NSTimer和图片延迟显示的用法。重点讨论了线程切换和线程常驻内存的概念。
最低0.47元/天 解锁文章
58

被折叠的 条评论
为什么被折叠?



