Collections.synchronizedList and synchronized

前端 未结 6 1972
星月不相逢
星月不相逢 2020-11-27 11:36
List list = Collections.synchronizedList(new ArrayList());
synchronized (list) {
    list.add(\"message\");
}

Is the bl

6条回答
  •  孤独总比滥情好
    2020-11-27 12:16

    Also Important to note that any methods that use Iterators for example Collections.sort() will also need to be encapsulated inside a synchronized block.

提交回复
热议问题