Realized that the thread pool has strange behavior when executing longer tasks. Experimented with mutexes and condition variables, but it still does not work correctly