of synchronisedList() ? Is it just to make the list access threadsafe ? or is there any other usage of this?
Exactly, just to make it's access methods thread safe. But the most useful form is java.util.Collections#synchronizedList(java.util.List<T>, java.lang.Object) where you can specify "lock" object. Knowing that object you can do compound actions atomically, like: syncList = Collections.synchronizedList(list, mutex); synchronized (mutex) { if (syncList.size() > 42) { syncList.clear() } else { ..... }
Обсуждают сегодня