// Figure out which groups to get rid of. We start off
// with the full set for which we are already listening,
// and eliminate any that are in both the new set and the
// current set.
Collection toRemove = new HashSet(groups);
toRemove.removeAll(newGrps);
// Add new groups before we remove any old groups, because
// removeGroups will start a new round of multicast requests
// if the set of groups becomes empty, and we don't want it
// to do so without reason.
groups.addAll(toAdd);