Refactored thread pool code after studying Executor