1.Pthread
- 1.介绍
Pthread是C语言的API,P是POSIX的简写 - 2.应用
注意:在使用Pthread之前,要包含头文件#import<pthread.h>
- 创建线程
//使用pthread创建线程对象
pthread_t thread;
NSString *name = @"threadOne";
//使用pthread创建线程
//第一个参数:线程对象地址
//第二个参数:线程属性 (名称\优先级)
//第三个参数:指向函数的指针
//第四个参数:传递给该函数的参数, 可以不传递
pthread_create(&thread, NULL, sum, (__bridge void *)(name));
void *sum(){
NSLog(@"%@",[NSThread currentThread]);
return NULL;
}