Java tutorial
//package com.java2s; import java.util.HashSet; import java.util.Set; public class Main { /** * Thread safe method to initialize sets * @param initSet * @return an initialized set of the desired object type */ public static synchronized <T> Set<T> initializeSets(Set<T> initSet) { if (initSet == null) { return new HashSet<T>(); } else { initSet.addAll(initSet); return initSet; } } }