-
thread pool question
Hello guys. I want to make a distributed system implementation(it's a task for my university). i was wondering if it would be a better idea to use a thread pool to serve clients instead of creating a new thread for each new request .
I google it and i find that there are advantages and disadvantages. My main idea for the project is to increase scalability and decrease the resources that the system use, so i believe that using a thread pool is a good idea. What's your opinion?
Thanks in advance.
-
Re: thread pool question
I'd say the advantages of a thread pool in this situation outweigh any of the disadvantages. Just my .02
-
Re: thread pool question
There are only a few cases I can think of where only creating new threads is used instead of thread pooling:
1. You have a tasks which run continuously (for example a GUI) at the same time as discrete tasks (processing a single request). These two items should be run on different threads so your continuous tasks don't become unresponsive. In this case it's much better to create single threads for the tasks you want to run continuously, then create a thread pool to handle the discrete tasks.
2. You're lazy and don't want to write a task scheduler. Seriously though, it's not to hard to create a simple queue (or heap/priority queue if certain tasks require higher priority) and have a synchronized thread enqueue and distribute tasks.
3. You have no idea what a thread pool is. Obviously this is not the case.
-
Re: thread pool question