Threading:

In computer programming, a thread is a process that is part of a larger process or application. For an application that can handle multiple concurrent users, a thread contains the information needed to serve one individual user or particular service request.

Threading refers to the number of processes that are run within a single application. In "multi-threading" a thread is created and maintained for each concurrent user or request from another application. The thread enables the application to know which user is being served as the application is alternately re-entered on behalf of different users. Multi-threading refers to running several processes in rapid sequence within a single application, regardless of which logical method of multi-tasking is being used by the operating system. Chili!Soft ASP supports multi-threading.

Multi-threading and task are similar and are often confused. Today's computers can only execute one instruction at a time, but because they operate so fast, they appear to run many applications and serve many users simultaneously. The computer operating system gives each application a "turn" at running, and then requires it to wait while another gets a turn. Each of these applications is viewed by the operating system as a "task" for which certain resources are identified and tracked. The operating system manages each application on the system (spreadsheet, word processor, Web browser) as a separate task and lets you look at and control items on a "task list." If the program initiates an I/O request, such as reading a file or writing to a printer, it creates a thread so that the application will be reentered at the right place when the I/O operation completes. Meanwhile, other concurrent uses of the application are maintained on other threads. Most of today's operating systems provide support for both multi-tasking and multi-threading. They also allow multi-threading within application processes so that the system is saved the overhead of creating a new process for each thread.

The Portable Operating System Interface.4a C specification provides a set of application programming interfaces that enable a programmer to include thread support in the application. Higher-level program development tools and application subsystems and middleware also offer thread management facilities. Object-oriented programming languages also accommodate and encourage multi-threading in several ways. Java supports multi-threading by including synchronization modifiers in the language syntax, by providing class developed for multi-threading that can be inherited by other classes, and by performing background "garbage collection" (recovering data areas that are no longer being used) for multiple threads.

See also:

Choosing a Threading Mode in "Chapter 3: Managing Chili!Soft ASP"

Copyright 2001 Sun Microsystems, Inc. All rights reserved. Legal Notice.