List of usage examples for java.util.concurrent CopyOnWriteArraySet addAll
public boolean addAll(Collection<? extends E> c)
From source file:Main.java
/** * This method, as the name suggests, will take the union of all the input sets, * creating an output, thread-safe set./* w w w .j a va 2 s . c o m*/ * @param collections input sets * @param <E> type of set items * @return a set that is the union of all input sets */ public static <E> Set<E> union(Collection<E>... collections) { final CopyOnWriteArraySet<E> result = new CopyOnWriteArraySet<E>(); for (Collection<E> collection : collections) { result.addAll(collection); } return result; }