refactor multi thread code in Spider