多线程

作者: 韩七夏 | 来源:发表于2016-04-06 00:15 被阅读21次

1.------------NSThread-----------

1>开线程的几种方式

*先创建,后启动

NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(run) object:nil];

[thread start];

*直接启动

[NSThread detachNewThreadSelector:@selector(run) toTarget:self withObject:nil];

[self performSelectorInbackground:@selector(run) withObject:nil];

2>其他用法

NSThread *current = [NSThread currentThread];

+ (NSThread *)mainThread;//获得主线程

3>线程间通信

performSelectorOnMainThread...

2.---------GCD(重点)-----------

1>队列的类型

*并发队列

获得全局的并发队列dispatch_get_global_queue

*串行队列

a.自创建

dispatch_queue_create

b.主队列

dispatch_get_main_queue

2>执行任务的方法类型

*同步(sync)执行

*异步(async)执行

3>了解队列和方法的配合使用

4>线程间通信

5>其他用法

dispatch_once

dispatch_after

dispatch_group_async\dispatch_group_notify

相关文章

  • 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/mboplttx.html