building indexes with threads