16 February 2011

Software Design Puzzle #7.2 - Thread Pools & Tasks

Please refer to previous two posts on the same problem - Implementing Thread Pools and Tasks. Here is the link for your convenience.
Yesterday, i added a requirement that i want to have a priority for tasks (a problem on data structures and algorithms). Today, i thought about another feature that gives a lot of flexibility (real OO design). In the above examples, we didn't talk much about the threads in thread pools. Can we try to make threads in thread pool dynamic entity - based on the need, the number of threads in thread pool should grow or shrink. Here are my next set of questions.

  1. What are the design decisions that i should take so as to make thread pool dynamic.
  2. How can i make threads, tasks, thread pool at the topmost level of abstraction and yet get many different concrete implementations.
  3. How can i ensure that the code I am going to develop after two years (due to new requirements) doesn't affect my code now (seal the code from modification for new requirements)
  4. How can i bring in hierarchy, levels of abstraction and modularity for better design?
  5. Do i have any design patterns?