#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的更多相关文章

  1. OC 线程操作2 - NSThread

        方法1 :直接创建 alloc init - (void)createNSThread111{ /* 参数1: (nonnull id) 目标对象 self 参数2:(nonnull SEL) ...

  2. OC 线程操作 - GCD队列组

    1.队列组两种使用方法2.队列组等待 wait /** 新方法 队列组一般用在在异步操作,在主线程写队列组毫无任何作用 */ - (void)GCD_Group_new_group___notify{ ...

  3. OC 线程操作 - GCD快速迭代

    - (void)forDemo{ //全都是在主线程操作的 ; i<; i++) { NSLog(@"--%@", [NSThread currentThread]); } ...

  4. OC 线程操作3 - NSOperation

    #import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...

  5. OC 线程操作 - GCD使用 -同步函数,异步函数,串行队列,并发队列

    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // GCD 开几条线程并不是我们 ...

  6. OC 线程操作 - GCD使用 -线程通讯, 延迟函数和一次性代码

    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // [self downImag ...

  7. OC 线程操作3 - NSOperation 实现线程间通信

    #import "ViewController.h" @interface ViewController () /** 图片 */ @property (weak, nonatom ...

  8. OC 线程操作 - GCD使用 - 栅栏函数

    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //同步函数无需栅栏函数 //栅栏 ...

  9. OC线程操作-GCD介绍

    1. GCD介绍 1.11.2 1.3 异步具备开启能力但是不是 一定可以开启 1.4 1.5 67. 8.

随机推荐

  1. 页面中href链接的碰撞

    问题: 如上图动态生成一个li列表,点击之后页面直接全部刷新了一遍 原因: 动态生成的代码(第一个图)中href链接地址与顶部页面(上图)中固定的href链接存在冲突 如果动态生成的列表指定的链接名称 ...

  2. AJAX之发送GET请求

    用jquery发送get请求 function AjaxSubmit1() { $.ajax({ //用jQuery发送 url: '/app04/ajax1/', type: 'GET', data ...

  3. JavaScript随机生成信用卡卡号的方法

    这段JS代码根据信用卡卡号产生规则随机生成信用卡卡号,是可以通过验证的,仅供学习参考,请不要用于非法用途,否则后果自负. var visaPrefixList = new Array( "4 ...

  4. Spring Cloud限流详解

    转自:https://blog.csdn.net/tracy38/article/details/78685707 在高并发的应用中,限流往往是一个绕不开的话题.本文详细探讨在Spring Cloud ...

  5. C#实现联合体

    [StructLayout(LayoutKind.Explicit, Size = )] public struct TypeTransform { [FieldOffset()] public fl ...

  6. 17.嵌入ace插件

    我们想 在problem-detail上具体显示代码 建一个component 叫 editor 将ace集成上去,算是他的画布吧. 支持各种语言 可以reset  提交写好的代码到server端编译 ...

  7. eclipse调试快捷键

    Eclipse中有如下一些和运行调试相关的快捷键. 1. [Ctrl+Shift+B]:在当前行设置断点或取消设置的断点.    2. [F11]:调试最后一次执行的程序.    3. [Ctrl+F ...

  8. 吴裕雄 15-MySQL LIKE 子句

    我们知道在 MySQL 中使用 SQL SELECT 命令来读取数据, 同时我们可以在 SELECT 语句中使用 WHERE 子句来获取指定的记录.WHERE 子句中可以使用等号 = 来设定获取数据的 ...

  9. 吴裕雄 03-mysql连接

    mysqli_connect(host,username,password,dbname,port,socket);参数 描述host 可选.规定主机名或 IP 地址.username 可选.规定 M ...

  10. oracle创建数据库步骤

    1.oracle安装成功后, cmd sqlplus,然后system/orcl as sysdba 2.更改scott的密码,scott的默认密码是tiger SQL> alter user ...