[runtime] Fix a crash if the thread name is set before the thread is started.