threads - threadpool - reset threads - stop threads without destroy - pthreads -linux
I'm asking me if it is possible to implement a threadpool in C with the feature to stop worker-threads (they should not return their calculated value) and push them back to the threadpool. Normaly, worker-threads get some work, finished it and get back to the threadpool.
1. Server starts threadpool with e.g 20 threads
2. Client sends request -> Server: all 20 threads waiting for work. 1 thread from threadpool get the work and is calculating
3. Client sends another request (previous request isn't finished)-> Server: resets the thread (send him back to threadpool) and another/or the same thread get the new work.
The previous request souldn't be finished because there are new informations and the previous calculation is out of date.
I dont want to create a new thread an kill the old because of performance issues.
The whole scenario is for LINUX and pthreads C. NO C++
Is there an implementation of such a feature, is it possible to implement it and how can i do it?