The threads of a process of the application can be organized depending on applications needs. The commonly used ways to organize them are:
1. Dispatcher-workers model:
- This model is used in designing a server process where the process consists of a single dispatcher thread and multiple worker threads.
- The dispatcher thread accepts client requests, examines them then dispatches the request to one of the free worker threads for processing.
- Each worker thread works on a different client request hence multiple client requests can be processes in parallel.
2. Team model
- All threads in this model behave equally such that there is no dispatcher-worker relationship for processing requests.
- Each thread gets and processes client requests on its own.
- This model is mostly used for implementing special threads within a process where each thread of the process is specialized to service a specific request.
- Multiple types of requests can be simultaneously handles by the process.
- Example:
3.Pipeline model:
- Applications based on producer consumer model uses this type the output generated by one part of the application is used as input to another part of the application.
- The threads in this model are organized as a process by the second thread and the output by second thread is used for processing the third thread and so on.
- The final output of the last thread in the pipeline is the final output of the process to which the thread belongs.
- Example: