Typically, the thumb: Anything w / Concurrent or Blocking in its name, otherwise. ConcurrentLinkedList , ConcurrentSkipListSet , LinkedBlockingDeque , LinkedBlockingQueue , etc. KeySet (), values ββ() of ConcurrentHashMap and ConcurrentSkipListMap, etc. Most java.util.concurrent ConcurrentModificationException , and that is good.
COWArrayList is usually useful for smaller or rarely modified collections ... and you should avoid the explicit set method.
One important note: using iterator.remove should always be preferred for Collection.remove (except for CHM.entrySet (), which is a bug in the buggy) (when available, the COWArrayList iterator does not support deletion). All non-random access structures will benefit from having to look for an element, which may be O (n).
Overall, ConcurrentModificationException was a half-baked idea and its implication. includes some side effects, including preventing the operation of hardware-transactional memory. This requires additional performance costs that are rarely needed. HashMap makes a terrible sense. w / volatile modCount (which is written upon modification and read on each itearyion, read is sorta free on x86, though).
source share