Fixed a bug in test thread_pool: the second run can lead to a deadlock