文档翻译 之 Threading Programming Guide

来源:互联网 发布:网络回拨电话 编辑:程序博客网 时间:2024/06/05 21:02

Introduction

简介

 

Threads are one of several technologies that make itpossible to execute multiple code paths concurrently inside a singleapplication.


Threads are one of several technologies

线程是一种使如下诉求成为可能的技术之一

 

To execute multiple code paths concurrently inside a singleapplication.

在一个单一的应用程序中并发执行多个代码路径。

 

偶个人理解,

类比多任务操作系统,是一个操作系统并发运行多个程序

多线程,是一个应用程序中并发执行多个微任务。

 

Although newer technologies such as operation objects andGrand Central Dispatch (GCD) provide a more modern and efficient infrastructurefor implementing concurrency, Mac OS X and iOS also provide interfaces forcreating and managing threads.

虽然已经有一些更潮的技术,如"operationobjects" 和 “GrandCentral Dispatch(GCD)”提供了更加现代化、更加高效的基础设施(底层支持),实现并发机制,但是MacOS X和iOS依然提供了 用于创建和管理线程的接口。

 

This document provides an introduction to the threadpackages available in Mac OS X and shows you how to use them.

本文档对MacOS X中有关线程的类库进行了介绍,并示范如何使用这些api。

 

This document also describes the relevant technologiesprovided to support threading and the synchronization of multithreaded codeinside your application.

本文档还讲述了支持线程的相关技术和程序内部的多线程同步(偶以为“多线程同步”也可以称“线程间通信”)。

Important

If you are developing a new application, you are encouragedto investigate the alternative Mac OS X technologies for implementingconcurrency.

重要提示:如果您正在开发新的应用程序,我们鼓励您研究其他由MacOS X实现的并发技术。

This is especially true if you are not already familiar withthe design techniques needed to implement a threaded application.

如果您并非已经熟悉 实现一个多线程应用程序 所需要的设计技术,更应该先研究下其他的并发技术。

These alternative technologies simplify the amount of workyou have to do to implement concurrent paths of execution and offer much betterperformance than traditional threads.

这些可供择选的技术,简化了我们的工作(实现线程并发所需),并且比传统的线程提供更好的性能。

For information about these technologies, see ConcurrencyProgramming Guide.

有关这些技术的信息,请参阅并发编程指南。

Organization of This Document

This document has the following chapters and appendixes:

本文档包含以下章节和附录:

“AboutThreaded Programming” introduces the concept of threads and their role inapplication design.

“关于多线程编程”介绍了线程(多线程)的概念及其在应用程序设计中的作用(角色)。

“ThreadManagement” provides information about the threading technologies in Mac OS Xand how you use them.

“线程管理”介绍了 Mac OS X中的线程技术 并 介绍如何使用这些线程技术。

“RunLoops” provides information about how to manage event-processing loops insecondary threads.

“运行循环”介绍了 在辅助线程中 如何管理事件处理循环。

“Synchronization”describes synchronization issues and the tools you use to prevent multiplethreads from corrupting data or crashing your program.

“同步” 介绍了 同步问题以及 可供使用的工具 用于防止多线程破坏数据甚至引起程序的崩溃。

“ThreadSafety Summary” provides a high-level summary of the inherent thread safety ofMac OS X and iOS and some of their key frameworks.

“线程安全总结”对Mac OS X、iOS以及一些关键框架中固有的线程安全进行了一个高度的概括。

See Also

另请参见

For information about the alternatives to threads, seeConcurrency Programming Guide.

有关线程的其他可供选择的技术,请参阅并发编程指南。

This document provides only a light coverage of the use ofthe POSIX threads API.

本文档只简单介绍了有关POSIXthreads API的使用方法。

For more information about the available POSIX threadroutines, see the pthread man page.

有关POSIX线程例程的更多信息,请参阅pthread的说明手册。

For a more in-depth explanation of POSIX threads and theirusage, see Programming with POSIX Threads by David R. Butenhof.

如果想要对POSIX线程及其用法有更深入的理解,请参阅由DavidR. Butenhof 编写的POSIX线程编程。

About Threaded Programming

关于线程编程

For many years, maximum computer performance was limitedlargely by the speed of a single microprocessor at the heart of the computer.

多年以来,计算机的性能主要受限于计算机的心脏----单一微处理器的的速度。

As the speed of individual processors started reaching theirpractical limits, however, chip makers switched to multicore designs, givingthe computer the opportunity to perform multiple tasks simultaneously.

虽然处理器的速度逐渐达到他们的物理极限,但是芯片制造商转向多核设计,为计算机同时执行多个任务提供了更多的机会。

And although Mac OS X takes advantage of these coreswhenever it can to perform system-related tasks, your own applications can alsotake advantage of them through threads.

Mac OS X在执行系统相关的任务充分利用这些核心的优势。通过某种方法,我们自己的应用程序也可以利用这些优势,这就是线程。

原创粉丝点击