Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

介绍下iOS中的多线程的几种实现方案,及各自的特点 #73

Open
tbfungeek opened this issue Feb 13, 2020 · 0 comments
Open

Comments

@tbfungeek
Copy link
Owner

tbfungeek commented Feb 13, 2020

iOS 系统中常用的多线程方案如下所示:

  • pthread
    pthread 是一种比较底层的多线程方案,它是通过C语言实现的 ,它的优点在于能够跨平台,可移植,并且有较高的效率。但是需要自己管理线程生命周期。

  • NSThread
    NSThread 是针对pthread的一层OC封装,它使用起来相对于pthread而言容易多了,但是和pthread一样还是需要自己管理线程生命周期。

  • GCD
    GCD 是基于C语言的,它也是我们在iOS开发过程中用得最多的一种多线程方案了,它的特点在于能够高效得使用CPU的多核特性,能够自动管理线程的生命周期。使用过程十分简单易用。

  • NSOperation
    NSOperation是基于GCD的面向对象封装,添加了线程依赖,并发数控制等功能。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant