Clean up the thread startup code by moving common code into a new start_thread () function.