US corporations face questions: HashMap is how to form an infinite loop? (With map most complete explanation)

Author | under this passionate

Original: blog.csdn.net/qq_36520235/article/details/86653136

The first states:

When the thread just a good expansion of the array, just at this time to prepare for the rehash, but this time two threads coming forced into execution, and the thread has two view after completion of the rehash state (upper half shows a thread, the lower half shows the is the thread two)

¨è¿ å ?? æ ?? é ???? ???? ?? å ¥ å ?? æ ???? ???? ¾ç è¿ °


The second states:

At this time, a thread has been awakened to begin operation rehash operations, the key of the node 5 or hung in the array subscript 1 on the position, and the key for the subsequent 5 is the node 9 (here before it actually expansion of the array 4, and certainly need to reposition subscripts ah, so here it is a modulo 4, and the corresponding list found in the corresponding array subscripts)¨è¿ å ?? æ ?? é ???? ???? ?? å ¥ å ?? æ ???? ???? ¾ç è¿ °

The third states:

From a first state then resumes processing node key 9, it should be hung on the tub are marked on the array in the order of the list 1 9 ----> 5 ----> NULL

¨è¿ å ?? æ ?? é ???? ???? ?? å ¥ å ?? æ ???? ???? ¾ç è¿ °

Fourth Status:

At this point in the process after 9 completed the third step, he found the back of the node 9 and a node 5 (5 is because this node left after the thread has two rehash completed), then he would put node 5 a thread portion in the first case is 5 ----> ---- 5. 9 (this portion of the rear 9-> 5 reserved state is the third left), where the endless loop is formed.

¨è¿ å ?? æ ?? é ???? ???? ?? å ¥ å ?? æ ???? ???? ¾ç è¿ °

At last

Welcome to public concern number: Programmer Herd, 66 replies, receive a 300 Java core knowledge pdf document summary!

When the content of these materials are the interview the interviewer will ask knowledge points, chapter points, including a lot of knowledge, including basic knowledge, Java collections, JVM, multi-threaded, spring principle, micro-services, Netty and RPC, Kafka , diary, design patterns, Java algorithms, databases, Zookeeper, distributed caching, data structures, and so on.


Guess you like

Origin juejin.im/post/5e75c4b16fb9a07ca530632b