Fix multithread problem.