Move thread spawning code to worker class.