Friday 30 April 2010

ConcurrentSet

Assumping you dont want to use CopyOnWriteArraySet,

Create a ConcurrentHashMap (faster than the above because of its striped locking) and create a set from it.

http://java.sun.com/javase/6/docs/api/java/util/Collections.html#newSetFromMap%28java.util.Map%29


public static <E> Set<E> newSetFromMap(Map<E,Boolean> map)

No comments:

Post a Comment