Multithreading versus Multiprocessing in Mac OS X.

By: Aaron Hillegass  

Multithreading gets a lot of hype because it enables you to take advantage of multiple processors and cores. Multithreading can also ensure that your application stays responsive while it is doing some sort of processing in the background. Multithreaded programming is, however, difficult: The activities of one thread often stomp on the data being used by another.

You can often use multiprocessing to get much of the benefit of multithreaded programming with few of the headaches. That is, instead of creating a new thread to do some sort of processing, simply create a whole new process.

Following are other benefits of multiprocessing over multithreading.

  • Rewriting the capabilities of many command line tools would be very time consuming.

  • If you have a memory leak in the external process, the operating system will clean up for you when the external process ends.

  • The external process can run as a user other than the application. Thus, the external process can have a set of permissions completely different from those of the application.

Although not as glamorous as multithreading, multiprocessing is probably more useful in real life.




Archived Comments


Most Viewed Articles (in Cocoa )

Latest Articles (in Cocoa)

Comment on this tutorial