bug fix. solve some thread hung problems