Thread pool implementation (Buggy).