画一下Java的集合collectionjava.util
和并发集合java.util.concurrent
的关系,
scala 非并发
scala 并发
java
detail
Type | Class | Description |
---|---|---|
List |
ArrayList | 数组,System.arraycopy |
LinkedList | 链表,node指向下一个node,如此循环,无容量限制 | |
CopyOnWriteArrayList | 数组,ReentrantLock(可重入,中断,限时,公平) | |
Map |
HashMap | 数组,Node<K,V>[] table |
LinkedHashMap | 链表,号称是最占内存的数据结构,newNode | |
TreeMap | 链表,RBT,sort,Entry<K,V> | |
ConcurrentHashMap | 数组,Node<K,V>[],CAS+synchronized | |
ConcurrentSkipListMap | 链表,CAS | |
Set |
HashSet | |
LinkedHashSet | ||
TreeSet | ||
ConcurrentSkipListSet | ||
CopyOnWriteArraySet | ||
Queue |
LinkedList | 双向链表 |
ArrayDeque | 数组,双向,head改变即可 | |
PriorityQueue | 数组,比较器 | |
ConcurrentLinkedQueue | 单向链表,CAS | |
BlockingQueue |
ArrayBlockingQueue | 数组,ReentrantLock |
LinkedBlockingQueue | 单向链表,put+take ReentrantLock | |
PriorityBlockingQueue | 数组,ReentrantLock | |
SynchronousQueue | 链表,transfer,CAS | |
Collections |
||
Arrays |