iOS 中NSOperationQueue,Grand Central Dispatch , Thread的上下关系和区别
In OS X v10.6 and later, operation queues use the libdispatch
library (also known as Grand Central Dispatch) to initiate the execution of their operations. As a result, operations are always executed on a separate thread, regardless of whether they are designated as concurrent or non-concurrent operations.
In iOS 4 and later, operation queues use Grand Central Dispatch to execute operations.
这2句话是NSOperationQueue Class Reference中的,这2句话表明NSOperationQueue是利用了GCD机制的,而Thread一直是最基本的多线程机制,那么它们3者的上下层关系便出来了:
Thread最基本,其次是GCD,封装的最高层是operation quque。在遇到多线程问题时,推荐使用Operation Queue。最新的AFNetWorking库也使用Operation Queue代替了GCD,代码开起来更简洁了。
那么这3中多线程方式具体的区别在哪里呢?
首先说NSThread,这个是系统最基本的多线程机制,一切其他机制都是由它衍生出来的。既然是最基本的,那么用起来也一定最复杂:它仅仅提供了最基本的线程机制,不会提供那些同步异步的各种机制。
其实,关键是区别CGD和NSOperationQueue 的区别。
最新文章
- UIButton(改变Title和image位置)
- 李洪强漫谈iOS开发[C语言-046]-统计输入字符个数
- python之网络爬虫
- LeetCode-Decode String
- Chrome 控制台不完全指南【转载】
- easyUI相关知识
- innerXml,outerXml,innerText的不同
- JMeter 监控和记录&;常用功能
- Python 简单socket模拟ssh
- 自己写的日志框架--linkinLog4j--框架可配置+提性能
- Elasticsearch安装详解
- PYthon3:简单几步实现冒泡排序
- logstash过滤器插件filter详解及实例
- OO课程学期末总结
- 从零开始编写自己的JavaScript框架(二)
- 雷林鹏分享:C# 预处理器指令
- php的websocket
- ccf认证模拟题之三---最大的矩形
- ZOJ 1654 Place the Robots建图思维(分块思想)+二分匹配
- Day21-Cookie
热门文章
- Java-LinkedHashSet
- session共享
- BZOJ-1951 古代猪文 (组合数取模Lucas+中国剩余定理+拓展欧几里得+快速幂)
- BZOJ3246 [Ioi2013]Dreaming
- event driven的一些概念
- HDU 5714
- ubuntu安装spark
- ASP.NET MVC 过滤器详解
- Spring MVC:使用SimpleUrlHandlerMapping的一个简单例子
- 数数字 (Digit Counting,ACM/ICPC Danang 2007,UVa 1225)