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, Mac OS X and iOS also provide interfaces for creating and managing threads.
This document provides an introduction to the thread packages available in Mac 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 Mac 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.
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 Mac 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.
“Thread Safety Summary” provides a high-level summary of the inherent thread safety of Mac OS X and iOS and some of their key frameworks.
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.
Last updated: 2010-04-28