IOS 多线程编程指南:1介绍

Introduction


Threads are one of several technologies that make it possible to execute multiple code paths concurrently inside a single application. Although newer technologies such as operation objects and Grand Central Dispatch (GCD) provide a more modern and efficient infrastructure for implementing concurrency, OS X and iOS also provide interfaces for creating and managing threads.

This document provides an introduction to the thread packages available in OS X and shows you how to use them. This document also describes the relevant technologies provided to support threading and the synchronization of multithreaded code inside your application.

Important: If you are developing a new application, you are encouraged to investigate the alternative OS X technologies for implementing concurrency. This is especially true if you are not already familiar with the design techniques needed to implement a threaded application. These alternative technologies simplify the amount of work you have to do to implement concurrent paths of execution and offer much better performance than traditional threads. For information about these technologies, see Concurrency Programming Guide.

简介


线程是一种技术,这种技术可以在单个应用中同时执行多个路径的代码。虽然新技术如对象操作和Grand Central Dispatch(GCD)提供了更现代、高效的并实现并发的方式,OS X和iOS依然提供的接口来创建和管理线程。

本文档提供了在OSX中包含的线程包的介绍,并向展示了如何使用它们。本文档还介绍了支持线程的相关技术,以及应用程序中实现多线程代码的同步。

重要提示:如果你正在开发一个新的应用程序,建议你被去研究其他OSX应用程序实现并发的技术。这一点挺重要,如果你还不熟悉设计一个多线程应用所需的技术。这些替代技术简化了你实现并发的工作量,并且提供了比传统的线程更好的性能。有关这些技术的信息,请参见并发编程指南《Concurrency Programming Guide》。

Organization of This Document


This document has the following chapters and appendixes:

  • About Threaded Programming introduces the concept of threads and their role in application design.
  • Thread Management provides information about the threading technologies in OS X and how you use them.
  • Run Loops provides information about how to manage event-processing loops in secondary threads.
  • Synchronization describes synchronization issues and the tools you use to prevent multiple threads from corrupting data or crashing your program.

文档的组织


文档有以下章节和附录:

  • About Threaded Programming 介绍线程的概念及其在应用程序设计中的作用。
  • Thread Management 线程管理提供了OSX中线程技术以及如何使用它们的信息。
  • Run Loops 提供了关于如何管理二次线程中的事件处理循环的信息。
  • Synchronization 同步描述的同步问题,和如何使用你的工具来防止多线程中数据的破坏或程序崩溃。
  • Thread Safety Summary 线程安全总结 提供了iOS和OS X和一些主要框架固有的线程安全的高度概括的总结。

See Also


For information about the alternatives to threads, see Concurrency Programming Guide.

This document provides only a light coverage of the use of the POSIX threads API. For more information about the available POSIX thread routines, see the pthread man page. For a more in-depth explanation of POSIX threads and their usage, see Programming with POSIX Threads by David R. Butenhof.

另见


更多关于其他线程技术的信息,请看: Concurrency Programming Guide(同步编程指南).

本文档仅仅提供了POSIX线程API的使用概述。有关可用的POSIX线程程序的更多信息,参见 pthread man page。更多POSIX线程使用的解释,参见戴维R. butenhof POSIX多线程编程。参见David R. Butenhof写的 Programming with POSIX Threads。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值