lock for multithread issues