refact and improve the ThreadPool