This section contains 286 words (approx. 1 page at 300 words per page) |
A thread is a portion of a program that runs separately during execution. As a program runs it spawns off separate functions as threads. Threads cannot run independently; they remain under the control of the program. Threads are sometimes referred to as "lightweight processes." Both threads and processes are each a sequential flow of control, but a thread is lightweight because it is running within the context of a complete program. It must share system resources belonging to the program of which it is a part.
A thread contains the information needed to serve a particular service request. If multiple users are using the program or concurrent service requests occur, a thread is created and maintained for each of them. Thread information is stored in a special data area, the address of which is recorded in the register.
Most operating systems support both multitasking and multithreading. Multithreading is the ability to run multiple threads simultaneously, with each thread performing a different task. This allows for faster execution of an application, especially when the application is run on a computer with multiple processors.
An application must be written in a certain way to take advantage of a multithreaded operating system. Some programming languages have built-in support for threading, and others require the use of APIs (Application Programming Interfaces). An example of a multithreaded application is a web browser that allows a user to scroll up or down on a web page while downloading additional images.
Multithreaded applications are complex to manage. Because threads share system resources, it is easy for one thread to tie up the CPU and prevent other threads in the program from executing. Different operating systems have different mechanisms for thread management.
This section contains 286 words (approx. 1 page at 300 words per page) |