Use Thread::spawn instead of deprecated task::spawn