{
// NSThread *thread=[NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"创建完线程直接(自动)启动"];
[NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"创建完线程直接(自动)启动"];
}
/**
* NSThread创建线程方式3
* 隐式创建线程, 并且直接(自动)启动
*/
-(void)creatNSThread3
{
//在后台线程中执行===在子线程中执行
[self performSelectorInBackground:@selector(run:) withObject:@"隐式创建"];
}
-(void)run:(NSString *)str
{
//获取当前线程
NSThread *current=[NSThread currentThread];
//打印输出
for (int i=0; i<10; i++) {
NSLog(@"run---%@---%@",current,str);
}
}
@end
调用线程1,打印结果为:
调用线程2
调用线程3
注:相关教程知识阅读请移步到IOS开发频道。













