collections + map
1. collections 包括 set list queue(为高并发 多线程准备put take)
安全 vector + hashtable 太重 自带锁 基本不用
hashtable(插入快 读慢) hashMap Collections.synchronizedMap concurrentHashMap(插入效率低 读效率高) 一路发展 。。升级
票超卖问题
vector
list
Collections.synchronizedList(strs)
concurrentLinkedQueue (poll 拿取) 多线程
---------------------------------------------------------------------------------------
concurrentHashMap concurrentSkipListMap(跳表 高并发排序) 因为在treeMap中 cas操作 过于复杂所以 concurrentSkipListMap 替代 concurrentTreeMap
--------------------------------------------------
(读多写少)copyOnWriteArrayList / copyOnWriteSet 读的时候不加锁 效率高 写的时候加锁 写时复制
----------------------------------------------------------
blockQueue 阻塞队列
concurrentLinkedQueue
Queue 方法 offer 返回值 poll 取 remove掉 peek 取 不会remove 线程安全 原子性
blockQueue 阻塞队列 方法 put take