IOS中的多线程实现:NSThread、GCD和NSOperation

1.NSThread

先创建,后启动

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

直接启动

 

2.GCD

3.NSOperation

线程 队列 同步 异步

一个任务放在一个队列里面 可以指定通过同步或者异步指定必须要用哪个线程来执行啊

队列的类型说明了要执行的顺序

 

队列就是一个任务表

线程就是一个执行任务的人

同步 异步就是线程执行阶段是否等待

As an optimization, this function invokes the block on the current thread when possible. 

posted @ 2015-09-19 18:06  ddhjy  阅读(109)  评论(0编辑  收藏  举报