【從入門到放棄-Java】併發編程-JUC-CopyOnWriteArrayList

前言

上文【從入門到放棄-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加鎖
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章