美文网首页
pthread 使用Demo

pthread 使用Demo

作者: 小如99 | 来源:发表于2018-07-03 22:53 被阅读33次
-(void)pthreadDemo
{

/*
 pthread 属于POSIX 多线程开发框架
 参数
  1:指向线程的指针
  2:线程属性
  3:指向函数的指针
  4:传递给函数的参数

 返回值:特别在C语言框架,非常常见
 如果是0,表示正确 noErr
 如果是非0,表示错误代码
 
 
 void * (*)     (void *)
 void * demo    (void  *param)
 返回值  函数指针   参数
 
 void * 等价于 OC id
 */

NSString *str = @"JJ";
pthread_t threadID;

int result = pthread_create(&threadID, NULL, &demo, (__bridge void *)(str));

if(result == noErr)
{
    NSLog(@"OK");//1
}else
{
    NSLog(@"error:%d",result);
    
}

}

void * demo(void  *param)
{

NSLog(@"%@,%@",[NSThread currentThread],param);

return  NULL;
}

相关文章

  • pthread 使用Demo

  • 多线程之NSThread

    Pthread 使用pthread必须盗用头文件#import 可以使用[NSThread...

  • iOS 多线程的部分使用

    1.pthread 说明:pthread的基本使用(需要包含头文件) 使用pthread创建线程对象 pthrea...

  • iOS多线程总结

    pthread 使用方法 pthread是C语言的多线程库,使用pthread需要首先添加头文件 NSThread...

  • pthread使用

    引言: 针对上一篇文章的 线程的概念 的理论知识的实践 第一步: 第二步(创建线程): 附上demo地址方便测试...

  • pthread多线程(C语言) + Socket

    pthread多线程(C语言) + Socket pthread是使用使用C语言编写的多线程的API, 简称Pth...

  • pthread(了解)

    pthread(了解) phtread 使用步骤导入头文件 纯C语言,pthread(p:posix,posix是...

  • pthread,NSThread的使用

    iOS中多线程的实现方案: 一、pthread的基本使用 pthread的基本使用(需要包含头文件) 二、NSTh...

  • 无标题文章

    03-Pthread | NSThread 标签: 面试基础知识(多线程) 01-pthread的基本使用(需要包...

  • IOS多线程-pthread & NSThread

    一、pthread的使用(几乎不用) 二、NSThread的使用(偶尔使用)

网友评论

      本文标题:pthread 使用Demo

      本文链接:https://www.haomeiwen.com/subject/rcksuftx.html