In-depth analysis of the principle of coroutine

V: ititit111222333

In-depth analysis of the principle of coroutine

1. The internal principle of Cl lections.sort sorting is in Java 6 Arrays.sort( and Col ctions.sort( use MergeSort, but in Java 7, the internal implementation is replaced by Tim Sort, which requires comparison between objects Strictly 2. HashMap principle, the changes made by java 8 In terms of structure implementation, HashMap is realized by array + linked list + red-black tree (JDK 1.8 adds the red-black tree part). HashMap only allows the key of a record to be null at most , Allow multiple records to be null. HashMap is not thread-safe. Concurrent HashMap is thread-safe. Resolve collisions: When conflicts occur, use the zipper method to link the nodes whose keywords are synonyms in a single-linked list. The hash list is long m, define a pointer array T composed of m head pointers, and insert the node with address i into the singly linked list with T(I) as the head pointer. In Java 8, conflicting elements exceed the limit (8), use red Black tree replacement linked list. 3. The difference between String and StringBuilder 1) Mutable and immutable: String is immutable, every time you execute "+", a new object will be generated, so String is not used in the case of frequent string changes to save Memory. 2) Is it multi-thread safe: StringBuilder does not add synchronization lock to the method, so it is not thread safe. Both StringBuffer and String are thread-safe. 4. The difference between Vector and Array 1) ArrayList is expanded by 50%+1 by default when the memory is insufficient, and Vector is expanded by 1 times by default. 2) Vector belongs to the thread safety level, but in most cases, Vector is not used, because thread safety requires greater system overhead. 5. The difference between HashMap and Hashtable 1) Historical reasons: Hashtable inherits the Dictonary class, HashMap inherits from abstract Map 2) HashMap allows empty key-value pairs, but at most only one empty object, while HashTable does not allow. 3) HashTable is synchronized, while HashMap is not synchronized, which is more efficient than HashTable 6.

Guess you like

Origin blog.51cto.com/15063244/2584081