1、vector
2、hashTable
vector和hashTable对所有方法都加上了sybchronized关键字,但是大多数场景并不需要线程安全,性能太低,因此vector和hashTable被弃用
3、可以使用collections包下的synchronized关键字对集合进行包装,Collections针对每种集合都声明了一个线程安全的包装类
4、concurrentHashMap,ConcurrentMap,ConcurrentLinkedQueue,ConcurrentLinkedDeque
5、copyOnWriteArrayList,加了锁的arrayList,加读写锁
6、copyOnWriteArraySet,加了锁的arraySet,加读写锁
hashSet底层是hashMap,hashMap的键可以为null,因为里面没有使用key.hashCode(),使用的hash(key),不会报空指针异常
ConcurrentMap和ConcurrentHashMap是分别对桶的头结点加锁。
ConcurrentLinkedQueue和ConcurrentLinkedDeque都是使用CAS机制。
不断循环尝试将tail->next设置成新节点