This usually means that each operation must be subdivided into smaller pieces that can be performed alternately. It also means that if one piece of one operation takes longer than it should to execute, the other half of the program loses out on needed processor time. If the half that gets shortchanged is the one that reads and processes input from the user, the application will suddenly seem sluggish and unresponsive. The diagram in Figure 1 illustrates the difference between single and multiple threads of execution in two hypothetical word processing programs. At one point in each program, the user selects Print from the File menu and the application begins sending the document to the printer.
Printing is done in the background, so the user can continue typing.
Confronted with the task of printing a document while remaining responsive to user input, a multithreaded application can delegate the printing process to a separate thread of execution. The input thread and print thread then run in parallel until printing is completed. A single-threaded application, by contrast, must alternate between printing and checking for user input, which slows down printing and decreases responsiveness. First, consider the single-threaded application on the left. When printing is begun, the application begins alternately checking for input and sending data to the printer.