fix a bug of thread synchronization