前言
上文【從入門到放棄-Java】併發編程-JUC-ConcurrentHashMap中,我們學習了常用的併發容器CurrentHashMap,本文我們來了解下List的併發容器:CopyOnWriteArrayList
直接來看源碼。
CopyOnWriteArrayList
add
/**
* Appends the specified element to the end of this list.
*
* @param e element to be appended to this list
* @return {@code true} (as specified by {@link Collection#add})
*/
public boolean add(E e) {
//使用synchronized加鎖