1) fixed some bugs in spawning multible threads