Improve the threadpool and avoid dead locks.