Allow ThreadPool to be configured with an arbitrary number of threads.
Do not hold the lock more than is necessary in FileDB.