Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 9.5


The Way of the Thread

Get started with threaded tasks

Issue: 9.5 (July/August 2011)
Author: JC Cruz
Author Bio: JC is a freelance engineering writer from North Vancouver, British Columbia. He frequently contributes articles to MacTech and REALStudio Developer. He also wrote for the now defunct Python Magazine, and is now writing for Dr Dobbs/TechWeb. Away from the writing pile, JC spends quality time with his foster nephew, as a proper uncle should. His email is anarakisware-at-gmail-dot-com if you'd like to contact him.
Article Description: No description available.
Article Length (in bytes): 39,002
Starting Page Number: 46
Article Number: 9508
Resource File(s):

Download Icon 9508.zip Updated: 2011-07-05 10:42:09

Related Web Link(s):


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.

These sub-sessions have a couple of things in common. First, they are tightly coupled to the main session and to each other. If a sub-session took too long to complete a task, the main session will appear to have stopped. Second, sub-sessions share the same resource pool as the main session. Only the main session can request new resources from its host system.

...End of Excerpt. Please purchase the magazine to read the full article.