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 *restri…
    方法1 :直接创建 alloc init - (void)createNSThread111{ /* 参数1: (nonnull id) 目标对象 self 参数2:(nonnull SEL) 方法选择器 ,调用的方法 参数3:(nullable id) 前面调用方法需要传递的参数 nil * //1.创建线程 NSThread *thread= [[NSThread alloc] initWithTarget:self selector:@selector(run:) object:@…
1.队列组两种使用方法2.队列组等待 wait /** 新方法 队列组一般用在在异步操作,在主线程写队列组毫无任何作用 */ - (void)GCD_Group_new_group___notify{ dispatch_queue_t queue = dispatch_queue_create("11", DISPATCH_QUEUE_CONCURRENT); dispatch_queue_t globalqueue = dispatch_get_global_queue(0, 0);…
- (void)forDemo{ //全都是在主线程操作的 ; i<; i++) { NSLog(@"--%@", [NSThread currentThread]); } /* 2018-06-27 11:33:44.226664+0800 5线程操作-GCD-快速迭代[7715:77291] --<NSThread: 0x60800006a9c0>{number = 1, name = main} 2018-06-27 11:33:44.226845+0800 5…
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ [self BlockOperation]; } -(void)BlockOperation{ //1.创建任务 NSBlockOperat…
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // GCD 开几条线程并不是我们可以控制的,而是系统来决定的, // [self asyncConcurrent]; // [self asyncSerial]; // [self syncConcurrent]; // [self syncSerial]; // [self test_get_global_queue];// [self…
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // [self downImage]; // [self delay]; [self once]; [self once]; [self once]; } /** 一次性代码: 整个应用程序只会执行一次 不可以放在懒加载里面, 如果在类中使用一次性代码, 创建的第二个对象, 就完全不会初始化, static : 全局变量 */ -(void…
#import "ViewController.h" @interface ViewController () /** 图片 */ @property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation ViewController - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{…
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //同步函数无需栅栏函数 //栅栏函数不能使用全局并发队列:不起作用 //栅栏函数不能使用全局并发队列:不起作用 //栅栏函数不能使用全局并发队列:不起作用 //栅栏函数不能使用全局并发队列:不起作用 //栅栏函数不能使用全局并发队列:不起作用 //栅栏函数不能使用全局并发队列:不起作用 dispatch_queue_t queue111 =…
1. GCD介绍 1.11.2 1.3 异步具备开启能力但是不是 一定可以开启 1.4 1.5 67. 8.…