iOS多线程
2016-03-18 10:45
567 查看
进程:一个正在运行的程序看作进程,它拥有独立运行所需的全部资源。(正在运行的qq)
线程:程序中独立运行的代码段。(接收qq消息的代码)
开辟一个主线程占1M,开辟一个子线程512kb。
线程:程序中独立运行的代码段。(接收qq消息的代码)
开辟一个主线程占1M,开辟一个子线程512kb。
//thread_1回调方法 - (void)thread_1Action:(NSString *)sender { //当子线程是我们手动开辟的,那么就需要我们自己来管理内存 @autoreleasepool { NSLog(@"thread_1_Info%@",[NSThread currentThread]); NSLog(@"参数:%@",sender); } } - (void)thread_2Action { @autoreleasepool { NSLog(@"Thread_2--%@",[NSThread currentThread]); } } - (void)thread_3Action { @autoreleasepool { NSLog(@"Thread_3333--%@",[NSThread currentThread]); } } //nsthread 学习 -(void)threadStudy { //通过便利构造器的方式创建thread对象,不用手动启动 [NSThread detachNewThreadSelector:@selector(thread_1Action:) toTarget:self withObject:@"thread_1"]; //通过alloc方式创建 NSThread *thread_2 = [[NSThread alloc] initWithTarget:self selector:@selector(thread_2Action) object:nil]; thread_2.name = @"Thread_2"; [thread_2 start]; thread_2.threadPriority = 1.0; NSThread *thread_3 = [[NSThread alloc] initWithTarget:self selector:@selector(thread_3Action) object:nil]; thread_3.name = @"thread_3"; [thread_3 start]; }
相关文章推荐
- iOS CocoaPods安装和使用图解
- CoreLocation框架地图定位(iOS9全适配)
- ios 给textField每四位添加一个空格
- iOS禁用返回手势
- iOS 手势
- iOS-关于极光推送小红点的设置问题
- GitHub 上排名前 100 的 IOS 开源库简介
- IOS 中控件相对坐标
- iOS:iOS开发系列–打造自己的“美图秀秀”(上)
- iOS内存那点事儿
- IOS百度地图导航开发功能实现简述
- iOS蓝牙4.0开发例子
- ios 颜色转图片
- IOS View 添加阴影效果
- iOS常用的第三方及实例
- iOS_正则表达式判断手机型号、邮箱、手机号、身份证、昵称、密码等
- iOS----CocoaPods的安装、使用和,原理+参考流程+常见问题
- iOS 9学习系列: ReplayKit框架入门
- iOS 纯代码适配iPhone6,6+
- iOS 手势操作:拖动、捏合、旋转、点按、长按、轻扫、自定义