OC 線程操作1 - pthread
阿新 • • 發佈:2018-06-22
interface AC class -s nbsp TE face spa nonnull
#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
OC 線程操作1 - pthread