1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| // ViewController.m
#import <pthread.h>
- (void)viewDidLoad { [super viewDidLoad]; //1.创建线程对象 pthread_t thread; //2.线程创建函数 //1).线程对象 -- 地址传递 //2).线程的属性 //3).指向函数的指针 //4).前面函数要接收的参数 -- NULL pthread_create(&thread, NULL, func, NULL); //3.判断两条线程是否相等 pthread_equal(); }
void *func(*void) { NSLog(@"%@-----", [NSThread currentThread]); return NULL; }
|