make thread switch work better.