In my classes of parallel programming the teacher mentioned three models, dynamic thread creation (create threads according to demand), thread pool (create a fixed amount of threads) and mixed or hybrid (create a number of threads at first, but you can create more if the demand increases too much and then return to the previous amount of threads when demand returns to normal)

I would like if someone could elaborate on the advantages and disadvantages of each model in general terms of performance, when it is best to use one in specific, etc...

  • 2
    Have you asked your teacher? You're paying an awful lot for that CS degree, be sure to get your money's worth. – RubberDuck Jun 25 '16 at 21:00
  • Not that he haven't explained well nor I don't know anything, but it was long ago and I need to get a really good qualification on the next test, so I'm trying to understand everything perfectly and I thought that maybe I could learn something more than what I already know from an answer here. – OiciTrap Jun 25 '16 at 21:22
  • I would like to know what's wrong with my questions... Why is it getting downvotes? – OiciTrap Jun 26 '16 at 3:52
  • I think it is because the question is asking about clarifying something in an academic context and there tend to be a lot of questions that are students trying to get their homework done. – Thomas Carlisle Jun 26 '16 at 14:37
  • Should I delete it? or what can I do to improve the question? – OiciTrap Jun 27 '16 at 5:05

A quick non-academic view:

Dynamic model:

  • Pros: uses only the number of threads needed.
  • Cons: the overhead of the thread creation and deletion during the processing. Consider also thread switching overhead, if the number of dynamic threads increases over the hardware supported limit.
  • Typical use case: handling event driven processes/sessions (e.g. I/O), where threads are frequently waiting and performance of thread creation is small compared to I/O (e.g. new incoming network connection).

Thread pool:

  • Pros: reduces overhead of thread management to the minimum. Constant throughput ?
  • Cons: If the size of the pool is too large (compared to hardware capacity or to processing needs), there might be an unnecessary switching overhead for unused threads.
  • Typical use case: handling work processes for queued input. More here

Mixed model:

  • can have the advantages (or the inconveniences if not careful !!) of both models. One possible approach is to size the a pool with an optimal size determined dynamically at runtime to maximize performance in view of hardware and processing needs.
  • Pros & cons of hybrid models can't be analyzed in general: they must be assessed case by case.
  • Why thread switching overhead, if the number of dynamic threads increases over the hardware supported limit.? It should happen any time the scheduler give another thread the CPU, not only when the number of threads increases over the hardware, or I'm wrong? – OiciTrap Jun 29 '16 at 16:58
  • 1
    @PatricioSard because if there are less active threads than available core there is no context switch required. See msdn.microsoft.com/en-us/library/ms682105(VS.85).aspx But you're right: This is only true considering the total number of threads on the os accross all concurrent processes. – Christophe Jun 29 '16 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.