Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Chapter 38. Threads

A thread is, simply put, a subprocess of your app that can execute even while other such subprocesses are also executing. Such simultaneous execution is called concurrency. The iOS frameworks use threads all the time; if they didn’t, your app would be less responsive to the user — perhaps even completely unresponsive. The genius of the frameworks, though, is that they use threads precisely so that you don’t have to.

For example, suppose your app is downloading something from the network (Chapter 37). This download doesn’t happen all by itself; somewhere, someone is running code that interacts with the network and obtains data. Yet a long download doesn’t prevent your code from running, nor does it prevent the user from tapping and swiping things in your interface. That’s concurrency in action.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial