首页 > 编程语言 > 详细

OC 线程操作1 - pthread

时间:2018-06-22 12:00:47      阅读:149      评论:0      收藏:0      [点我收藏+]

#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

原文:https://www.cnblogs.com/qingzZ/p/9212268.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!