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
  • PrintPrint

Threads

An alternative to inserting calls to CFRunLoopRunInMode throughout your code is to place the rendering code in another thread. Threading is an enormous topic, so this section focuses mainly on the Objective-C specific aspects of threading.

Threading introduces nondeterminism into your application: The state of a nonthreaded application always changes in the same way given the same inputs; the state transitions can be written down in a line as shown in Figure D.1. The program must be correct for just that one sequence. The state of a threaded application changes in as many ways as there are possible interleavings of threads, as shown in Figures D.2 and D.3. The state transitions can only be written down as a directed acyclic connected graph, an arc representing a transition, as shown in Figure D.3. The program must be correct for any path taken through this graph.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint