Multitasking within a single program. It allows multiple streams of instructions (threads) to execute concurrently within the same program, each stream processing a different transaction or message. Each stream is a "subprocess," and the operating system typically cooperates with the application to handle the threads.|
In order for a multithreaded program to achieve performance gains, it must be run in a multitasking or multiprocessing environment, which allows multiple operations to take place simultaneously.
It Depends on the Application
Certain types of applications lend themselves to multithreading. For example, in an order processing system, each order can be entered independently of the other orders. In an image editing program, a calculation-intensive filter can be performed on one image, while the user works on another. Multithreading is also used to synchronize audio and video streams.
A symmetric multiprocessing (SMP) operating system uses multithreading to allow multiple CPUs to be controlled at the same time. See SMP.
Multithreading generally uses re-entrant code, which cannot be modified when executing, so that the same code can be shared by multiple programs. See re-entrant code, multiprocessing and hyperthreading.