fix bug caused by multiple thread synchronization