码迷,mamicode.com
首页 > 其他好文 > 详细

NSThread

时间:2016-01-15 22:58:21      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

1. 初始化

方法一:隐式创建

[NSThread detachNewThreadSelector:<#(nonnull SEL)#> toTarget:<#(nonnull id)#> withObject:<#(nullable id)#>];

方法二:隐式创建

[self performSelectorInBackground:<#(nonnull SEL)#> withObject:<#(nullable id)#>];

方法三:初始化方法

NSThread *thread = [NSThread alloc]initWithTarget:<#(nonnull id)#> selector:<#(nonnull SEL)#> object:<#(nullable id)#>];

  [thread start];

 方法四:继承(子类化)创建

(1)创建NSThread类的子类

(2)覆写-(void)main方法

(3)创建

2. 属性设置

[thread setName:<#(NSString * _Nullable)#>]; //设置线程的名字

thread.stackSize = 512;  //设置线程的栈空间

[thread.threadDictionary setValue:<#(nullable id)#> forKey:<#(nonnull NSString *)#>];  //设置线程的参数  只读属性

 [thread setThreadPriority:<#(double)#>];  //设置线程的优先级

    

 

 

NSThread

标签:

原文地址:http://www.cnblogs.com/xiaojiang-123/p/5134444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!