NSThread 创建的三种方式:
// 创建线程 object是传给方法的参数 NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(run:) object:@"jack"]; // 启动线程 [thread start];复制代码
//不需要alloc start 来创建子线程[NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"rose"];复制代码
//不显示NSThread 来创建子线程[self performSelectorInBackground:@selector(run:) withObject:@"jack"];复制代码