I understand Poco::ThreadPool::addCapacity(n) will add "n" to the current thread pool capacity. So you probably want something like pool.addCapacity(pParams->getMaxThreads()-pool.capacity());

You could even remove the check of max thread size > pool capacity, because a negative number passed to addCapacity will decrease the number of max threads on the pool, and that seems to be good too.