[threadpool] Fix overflow of max number of worker threads