pthread的简单用法
void *run(void *data) {
NSThread *current = [NSThread currentThread];
for (int i = 0; i<20000; i++) {
NSLog(@"run---%@", current);
}
return NULL;
}
- (IBAction)btnClick {
// 1.获得当前的线程
NSThread *current = [NSThread currentThread];
NSLog(@"btnClick---%@", current);
// 2.执行一些耗时操作 : 创建一条子线程
pthread_t threadId;
pthread_create(&threadId, NULL, run, NULL);
}