Refactoring task 5 of threads.