NSThread

方式一:手动开启线程

NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(test) object:nil];

[thread start];

方式二:自动开启线程

[NSThread detachNewThreadSelector:@selector(test) toTarget:self withObject:nil];

方式三:直接在后台创建一个子线程

[self performSelectorInBackground:@selector(test) withObject:nil];

退出线程

[NSThread exit];

你可能感兴趣的:(NSThread)