A program can be implemented as a single, complex entity that performs multiple functions among the different parts of the program. A more simple solution consists of implementing several entities, each entity performing a part of the program and sharing resources with other entities. By using multiple entities, a program can be separated according to its distinct activities, each having an associated entity. These entities do not have to know anything about the other parts of the program except when they exchange information. In these cases, they must synchronize with each other to ensure data integrity.
Threads are well-suited entities for modular programming.
The following common software models can easily be implemented with threads. All these models lead to modular programs. Models may also be combined to efficiently solve complex tasks. Typically, the master controls how many slaves there are and what each slave does. A slave runs independently of other slaves.