The Way of the Thread
Get started with threaded tasks
Issue: 9.5 (July/August 2011)
Author: JC Cruz
Article Description: No description available.
Article Length (in bytes): 25,212
Starting Page Number: 46
RBD Number: 9508
9508.zip Updated: Tuesday, July 5, 2011 at 11:17 AM
Related Web Link(s):
Known Limitations: None
Excerpt of article text...
Threads serve an important role in many modern software products. So today, we look at the nature of threads and their benefits. We will study the Thread class, its properties and methods. We will glance at the mutex concept and learn how it interacts with a thread. Finally, we will study the basic thread cycle, plus some useful ways to manage a thread.
From Process to Process
When an application launches, the first thing it does is to create a main session (Figure 1). The main session remains active until the application gets a quit signal from the user or it runs into an unhandled exception. Both will cause the main session to terminate. But only a quit signal will make the session save its user data and state.
Now the main session can spawn two or more sub-sessions (Figure 2), each one handling a specific task. Sub-session A may present a window view through which the user interacts. Sub-session B may maintain an input/output stream to an external file. And sub-session C may connect itself to the network cloud.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.