thread pool: refactoring