fix bug in multithread