Frontier Tutorials / Working With Threads

Working With Threads

Tutorial Contents
Working With Threads
What Are Threads?
Semaphores--Traffic Control for Threads
How to Be Thread-Friendly
Rules of Thread Safety
An Example
Frontier's Thread Verbs
Thread Utilities
Glossary of Terms
About the Author

Threads. The term strikes fear in the hearts of programmers everywhere. But with a basic understanding of how threads work, coupled with careful programming, threads can provide great advantages to your programs.

Need to construct a web page and fill it in with data from an external database? Fire off the data request in a separate thread, so it executes while you build the rest of the page. Then substitute in the results.

Or fire off the data request, then return a partial page (using sendPartial) to the user while you wait for the search thread to complete.

Split a website search into multiple threads that search sections of the site separately, or fire off search queries to multiple search engines, then combine the results.

Not Trivial, But Not So Difficult, Either

This tutorial is intended for fairly experienced programmers or scripters. It begins with an overview of threads, then focusses down on how to work with threads in the Frontier environment.

If you see a term that you don't recognize, or that you're not sure you understand, jump to the Glossary of Terms for a definition.

This tutorial will help you to speed up and streamline your web applications and CGIs. You'll get faster results by working while you wait.

On to the Threads Overview.

Author: Samuel Reynolds
Email: sam@spinwardstars.com
First Published: 1998/11/13
Last Revision: 2002/07/29
Keywords: thread,threads,multithreaded,semaphore,semaphores,share,shared,shared data,parallel,parallel processing,CGI,CGIs,web,www,world wide web
Level of Difficulty: Intermediate

Tutorial Contents
Working With Threads
What Are Threads?
Semaphores--Traffic Control for Threads
How to Be Thread-Friendly
Rules of Thread Safety
An Example
Frontier's Thread Verbs
Thread Utilities
Glossary of Terms
About the Author