OC 线程操作1 - pthread

#import "ViewController.h"

#import <pthread.h> //1.需要包含这个头文件

 

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    //2.创建线程对象

    pthread_t p;

    

    //3.创建线程

    /*

     参数1 : pthread_t  _Nullable *restrict _Nonnull, 线程对象,传递地址

     参数2 : const pthread_attr_t *restrict _Nullable, 线程属性 , NULL

     参数3 : void * _Nullable (* _Nonnull)(void * _Nullable), 指向函数的指针

     参数4 : void *restrict _Nullable, 函数需要的参数

     */

    pthread_create(&p, NULL, task, NULL);

}

 

void *task(void *pama){

    return NULL;

}

 

@end

猜你喜欢

转载自www.cnblogs.com/qingzZ/p/9212268.html