It describes four functional models that can be a basis for constructing multithreaded applications. The concepts and techniques introduced here are described in more detail in Chapter 2 and in this guide's platform-specific appendixes. This chapter's last section introduces the components of the DECthreads package, in particular the pthread and tis interfaces, and how those components support building multithreaded applications and thread-safe libraries. 1.1 Advantages of Using Threads Multithreaded programming means organizing and coding a program so that instances of its routines, called threads, can execute concurrently in the same process. Using threads can improve a program's performance on uniprocessor systems by permitting the overlap of input, output, or other slow operations with computational operations.
Threads are useful in driving slow devices such as disks, networks, terminals, and printers.
A multithreaded program can perform other useful work while waiting for the device to produce its next event, such as the completion of a disk transfer or the receipt of a packet from the network. Using threads can also be advantageous when constructing an application's user interface. Consider the typical arrangement of a window system. If the user invokes multiple actions, multiple threads can perform the actions in parallel. Using threads is especially advantageous when building a distributed system.