an implementation of the threadpool pattern in C