void (MacScrollBarUI toAdd, MacScrollBarUI toRemove, List<? super MacScrollBarUI> list) { synchronized (UI) { Iterator<Reference<MacScrollBarUI>> iterator = UI.iterator(); while (iterator.hasNext()) { Reference<MacScrollBarUI> reference = iterator.next(); MacScrollBarUI ui = reference.get(); if (ui == null || ui == toRemove) { iterator.remove(); } else if (list != null) { list.add(ui); } } if (toAdd != null) { UI.add(new WeakReference<>(toAdd)); } } }