多线程

作者: CyberDunk1997 | 来源:发表于2020-09-27 15:12 被阅读0次

一天精通iOS多线程[https://juejin.im/post/6858126631760986126#heading-10]

NSOperation

1.NSOperation创建非主队列

    //1.创建非主队列
    NSOperationQueue *queue = [[NSOperationQueue alloc]init];
    //2.封装一个操作
    NSBlockOperation *op1 = [NSBlockOperation blockOperationWithBlock:^{
        NSLog(@"1----%@",[NSThread currentThread]);
    }];
    //3.队列添加操作
    [queue addOperation:op1];
  • addOperation会调用[op1 start];方法,[op1 start];又会调用[op1 main];方法

NSThread

1.创建线程的方法

    NSThread *thread = [[NSThread alloc]init];
    
    [thread start];

封装NSOperation、NSThread

  • 通过封装一个新的类,继承NSOperation或者NSThread,并重写它的main方法,即可快速调用一个封装好方法的线程。

相关文章

  • iOS多线程 NSOperation

    系列文章: 多线程 多线程 pthread、NSThread 多线程 GCD 多线程 NSOperation 多线...

  • iOS多线程 pthread、NSThread

    系列文章: 多线程 多线程 pthread、NSThread 多线程 GCD 多线程 NSOperation 多线...

  • iOS多线程: GCD

    系列文章: 多线程 多线程 pthread、NSThread 多线程 GCD 多线程 NSOperation 多线...

  • iOS多线程运用

    系列文章: 多线程 多线程 pthread、NSThread 多线程 GCD 多线程 NSOperation 多线...

  • iOS多线程基础

    系列文章: 多线程 多线程 pthread、NSThread 多线程 GCD 多线程 NSOperation 多线...

  • 多线程介绍

    一、进程与线程 进程介绍 线程介绍 线程的串行 二、多线程 多线程介绍 多线程原理 多线程的优缺点 多线程优点: ...

  • iOS进阶之多线程管理(GCD、RunLoop、pthread、

    深入理解RunLoopiOS多线程--彻底学会多线程之『GCD』iOS多线程--彻底学会多线程之『pthread、...

  • iOS多线程相关面试题

    iOS多线程demo iOS多线程之--NSThread iOS多线程之--GCD详解 iOS多线程之--NSOp...

  • 多线程之--NSOperation

    iOS多线程demo iOS多线程之--NSThread iOS多线程之--GCD详解 iOS多线程之--NSOp...

  • iOS多线程之--NSThread

    iOS多线程demo iOS多线程之--NSThread iOS多线程之--GCD详解 iOS多线程之--NSOp...

网友评论

      本文标题:多线程

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