#import "ViewController.h"
#import <pthread.h>
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)btnClick:(id)sender {
//1.创建线程对象
pthread_t thread;
//2.创建线程
/*
第一个参数:线程对象
第二个参数:线程属性
第三个参数:指向函数的指针
第四个参数:函数的{参数}
*/
pthread_create(&thread, NULL, run, NULL);
pthread_t thread1;
pthread_create(&thread1, NULL, run, NULL);
}
void *run(void *param)
{
for (NSInteger i = 0; i<10000; i++) {
NSLog(@"%@",[NSThread currentThread]);
}
return NULL;
}
@end