preven thread crash when multiple thread process in the same time