ConcurrentHashMap在JDK1.7与JDK1.8中数据结构不一样,JDK1.8的锁的粒度会比JDK1.7中小。
ConcurrentSkipListMap跳表
ArrayList 扩容方式:
private void grow(int minCapacity) {
// overflow-conscious code
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
if (newCapacity - MAX_ARRAY_SIZE > 0)
newCapacity = hugeCapacity(minCapacity);
// minCapacity is usually close to size, so this is a win:
elementData = Arrays.copyOf(elementData, newCapacity);
}
int newCapacity = oldCapacity + (oldCapacity >> 1);
newCapacity = oldCapacity * 1.5
Set集合:
Queue API:
Semaphore:
Fork Join: