Hello. A question:
In javadoc it is written that for
thread-safeaccess to anArrayListуit needs to be decorated throughCollections.synchronizeList. I understand that this method simply returns thelistmethods of which aresynchronized, is that so?From the same javadoc:
List list = Collections.synchronizedList(new ArrayList()); synchronized(list) { Iterator i = list.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }
It is imperative that the list of users over it: ...
Why in this case manually synchronize through synchronized(list) ? Or should it be done only when working with iterators, and not necessarily if you access the sheet via get() , add() , set() ? Thank.
Vector. One of his mention causes the wrath of the gods :) By the way, the decorator itself is not a crutch, and in some cases this approach may be useful. But only in some. - cy6erGn0m