Refactor thread init loop to not use break