HashMap,HashSet,ArrayList都不具备线程安全。
可以用
Set s=Collections.synchronizedSet(new Hashset<...>());
Map m=Collections.synchronizedMap(new HashMap<...>());
List l=Collections.synchronizedList(new ArrayList<...>());
获得被同步后的版本。
也可以用ConcurrentHashMap等同步工具代替
HashSet不是线程安全的,HashTable是线程安全的。如果数据量很大,又要线程安全,建议使用Vector