Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed CS code to match previous NCE; same as my offline comment

...

Code Block
bgColor#ccccff
final class IPHolder {
  private final List<InetAddress> ips = Collections.synchronizedList(new ArrayList<InetAddress>());

  public void addIPAddressaddAndPrintIPAddresses(InetAddress address) { 
    synchronized (ips) { 
      ips.add(address);
    }
  }

  public void addAndPrintIPAddresses(InetAddress address) {
    synchronized (ips) {
      addIPAddress(address);
      InetAddress[] addressCopy = (InetAddress[]) ips.toArray(new InetAddress[0]);           
      // Iterate through array addressCopy ...
    }
  }
}

...