多线程的开发中绝对不要相信一次执行的结果
0.ios中四种多线程技术
1.pthread,c语言环境,复杂,跨平台,通用
2.NSThread,面对对象,集成,手动线程控制
3.GCD(并非多线程技术),并发技术,ios推荐用法
4.NSOperation
1.pthread(简单使用)
pthread 是属于 POSIX 框架,多线程开发框架,通用性强,跨平台
用法:


参数解释:函数返回值类型 int
1.指向线程代号的指针
2.线程的属性
3.指向函数的指针
4.传递给该函数的参数
用法:



运行结果:

2.NSThread



运行结果:

其他常用方法:



结果如下

网友评论