refactor thread ,io