Fixed a bug in threads that occured when switching from a thread