private synchronized boolean basicAddProfile(Profile p) {
    // must synchronize when modifying profile array

    // don't add more than once, but replace existing profile
    int index = indexOfMemberId(p.getId());
    if (index >= 0) {
      Profile[] oldProfiles = profiles; // volatile read
      oldProfiles[index] = p;
      profiles = oldProfiles; // volatile write
      profilesVersion++;
      return false;
    }

    // minimize volatile reads by copying ref to local var
    Profile[] snap = profiles; // volatile read
    Profile[] newProfiles = (Profile[]) ArrayUtils.insert(snap, snap.length, p);
    Objects.requireNonNull(newProfiles);

    profiles = newProfiles; // volatile write
    profilesVersion++;
    setNumActiveProfiles(newProfiles.length);

    return true;
  }
@return true if new profile added, false if already had profile (but profile is still replaced
        with new one)
geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionAdvisor.java