1, Collection interfaces and packaging Collections:
Collection Concept: is a collection of interfaces, the method provides a common interface for collection of objects for basic operations.
It has the following structure:
|--List
| |--LinkedList
| |--ArrayList
| |--Vector
| |--stack
|--Set
Collections: includes various static method of relating a set of multi-state operation, and can not be instantiated class, corresponding to a tool class.
2、HashMap、HashTable和ConcurrentHashMap:
HashMap features : thread-safe, allow incoming null value, the order can not be saved mapping. The array (the default length of 16) + the list, the latter jdk1.8, if it is greater than the length of the chain 8, will be transformed into red-black tree.
ps: HashMap thread-safe, because when multiple objects at the same time on the same HashMap operation, will lead to dirty read, data loss occurs.
Details Reference: https: //www.cnblogs.com/aspirant/p/8908399.html
HashTable: can be understood as thread-safe HashMap, Why is thread-safe, because it's put, remove, get modified methods are synchronized, to synchronize naturally thread-safe.
ConcurrentHashMap: is thread safe and efficient HashMap, the array of structures and HashEntry Segment array structures, Segment is a reentrant lock of ReentrantLock , ConcurrentHashMap role in the lock, HashEntry for storing the key data .
A ConcurrentHashMap contains a Segment array , the structure of Segment HashMap and the like, and an array of a list structure , a Segment contains a HashEntry array, each element of a linked list structure is HashEntry, each guarding a Segment array HashEntry element, when the data array HashEntry modified, it must first obtain the corresponding Segment lock.
Why is security: the use of sub-lock technology, to Segment array of every element locked .
Lock technology segments: roughly meaning is, the storage resources into multiple segments, each segment to give these resources with a lock, so that thread to access a resource which does not affect other threads access to other segments of resources, greatly improving the effectiveness.