Chapter 9

Working in the Background

In This Chapter

arrow Understanding background operations

arrow Keeping your app’s events on schedule

arrow Using a thread to download web data

Every current Macintosh comes with several CPUs, each of which can perform independently of the others. The minimalist MacBook contains an Intel Core 2 Duo CPU; the beefiest Macintosh Pro comes with two separate six-core Intel CPUs (and yes, I dream about that one). OS X is written with multitasking in mind, and the apps you run on your Mac can take advantage of multiple CPUs without your having to tell them to do so. So iTunes is downloading tonight’s video while playing its theme song, your e-mail app is retrieving the latest messages from your office while you’re writing, and your web browser is displaying the new messages from your friends at your favorite social-networking site, while you’re translating some German.

Your Mac app can use all the CPUs on the machines where your users install it. Normally, your app will operate on just one CPU, submitting its programming instructions to the processor. But you can enhance your app’s performance, even while running on just one CPU, if you set up some of your code to operate ...

Get Mac® Application Development For Dummies® 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.