fix a thread problem