Add multithread code with lock;