20Multithreading
Multithreading is another method for achieving concurrency in your application. While multiprocessing uses multiple independent processes with their own address spaces and resources, threads are multiple execution streams that all run within a single application, with a single address space, all sharing the available resources.
Multithreading, like multiprocessing, can take advantage of multiple CPUs. You can also use it to simplify some kinds of programming. Each thread can go on its merry way, computing values and calling functions that block, while other threads can run independently and are unaffected. One very common use of threads is handling requests in a network server (like a web server). A new connection is accept() ...
Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.