Java -- dead loop caused by HashMap in high concurrency

Basic implementation of HashMap (before JDK 8) HashMap usually uses a pointer array (assumed to be table []) to disperse all keys. When a key is added, it will calculate the subscript i of the array through the key through the Hash algorithm, and then insert this into table[i]. If two different keys are counted in the same I, it is called conf ...

Posted by skyriders on Sat, 22 Jan 2022 17:37:34 +0100

JDK1. 8 detailed decomposition of concurrenthashmap source code 01

Article reference: Xiao Liu speaks the source code Source code analysis of ConcurrentHashMap_ 01 member attribute, internal class and construction method resolution 1. Introduction ConcurrentHashMap is a thread safe version of HashMap. Internally, it also uses the structure of (array + linked list + red black tree) to store elements. Compa ...

Posted by brittny85 on Thu, 20 Jan 2022 05:14:36 +0100

An interview was asked about ArrayMap, the principle and source code analysis in detail

1, Foreword In SparseArray detailed explanation and source code analysis, we are familiar with the basic usage, characteristics and implementation principle of SparseArray. There is also an equally important data structure ArrayMap in the toolkit of the Android SDK. Its purpose is to replace HashMap when the amount of data is small, such as hu ...

Posted by signer on Wed, 19 Jan 2022 07:47:22 +0100

JDK1. Detailed interpretation of 7hashmap source code

(the source code analysis of this article exists in the comments of the code block. Please watch it patiently) Before we start, let's briefly understand the following HashMap. The backbone of HashMap is an entry array. Entry is the basic unit of HashMap. Each entry contains a key value pair. (in fact, the so-called Map is actually a collection ...

Posted by Redneckheaven on Tue, 18 Jan 2022 19:01:33 +0100

JAVA -- Set and Map

Set 1. Overview and characteristics A collection that does not contain duplicate elements. More specifically, set does not contain a set that satisfies e1 Equals (e2) has element pairs e1 and e2 and contains at most one null element.The data in the Set collection is out of order (because the Set collection has no subscript)Set does not al ...

Posted by ATS16805 on Sun, 16 Jan 2022 16:23:17 +0100

Summary of knowledge points [nanny level]

1, Collection Features of collection class: it provides a storage type with variable storage space, and the stored data capacity can be changed at any time Collection collection overview Is the top-level interface of a single column Collection. It represents a set of objects, which are also called Collection elementsJDK does not provide an ...

Posted by JayBlake on Sun, 16 Jan 2022 07:08:11 +0100

Interpretation of jdk8 HashMap source code based on Java

HashMap is a Map interface implementation based on hash table. It exists in the form of key value storage, that is, it is mainly used to store key value pairs. Among them, key value can be null, and the mapping is not orderly. The implementation of HashMap is not synchronous, that is, the thread is not safe. 1, Storage characteristics 1.1 ...

Posted by martor on Sat, 08 Jan 2022 17:21:02 +0100

Underlying implementation principle of HashMap

To understand the underlying implementation principle of HashMap, we must first analyze some underlying source code of HashMap public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable We can see that HashMap inherits AbstractMap and implements Map, Cloneable and Serializable interfa ...

Posted by roseplant on Sat, 01 Jan 2022 17:32:06 +0100

Java - Collection 2-5 (Map)

Map Overview and use of Map collections Overview of Map Collections Interface Map < K, V > K: Key type; V:Type of valueMap keys to objects of value; Cannot contain duplicate keys; Each key can be mapped to at most one valueExamples: student number and name 001 Small White 002 Small Black 003 Small Red Objects that create a Map collect ...

Posted by lopes_andre on Wed, 29 Dec 2021 18:50:12 +0100

Details of Java performance optimization that affect performance

1, Foreword  details of Java performance optimization affecting performance - continued. I intend to write the whole series of articles with this title slowly. This is the first article entrance . This time, the content mainly comes from the book "actual combat of Java program performance optimization". It is a reading note. Int ...

Posted by rammac13 on Thu, 09 Dec 2021 08:37:07 +0100