Unsafe solution of Java collection class under multithreading

2, Collection class unsafe 2.1ArrayList thread is unsafe 2.1.1 example Single thread public class NotSafeDemo { //Single thread is safe public static void main(String[] args) { List<String> list = Arrays.asList("a", "b", "c"); list.forEach(System.out::println); } } a b c Multithreading public class NotS ...

Posted by coffeehead on Sat, 25 Sep 2021 04:51:09 -0700

Two column set Map

Double column set: key: value public class MapDDDDemo { public static void main(String[] args) { Map map = new HashMap<Integer,String>(); map.put(1,"Hello"); map.put(2,"world"); map.put(3,"hello"); System.out.println("map Length:"+map.size()); System.out.println("map Include key ...

Posted by joshuamd3 on Fri, 24 Sep 2021 21:36:05 -0700

Java Collection source code summary Collection source code annotation translation and analysis in both Chinese and English

edition JDK8(JDK1.8) Collection interface source code focus 1. The root interface in the set hierarchy. A set represents a group of objects called its elements. Some sets allow repeated elements, while others do not. Some are ordered and some are disordered. 2. The interface class defines various specifications, including method specification ...

Posted by Opticon on Fri, 24 Sep 2021 21:13:19 -0700

Set - Map interface

Characteristics of Map interface implementation class Map and Collection exist side by side. Used to save data with mapping relationship: key valueThe key and value in the Map can be data of any reference type and will be encapsulated in the HashMap$Node objectDuplicate key s in Map are not allowed. The reason is the same as HashSet. The sourc ...

Posted by pinehead18 on Thu, 23 Sep 2021 04:15:21 -0700

Relationships and usage of Collection,List,Set

Relationships and usage of Collection,List,Set 1. Overview and use of Collection collections Summary: Is the top-level interface to a single-column Collection that represents a set of objects, also known as elements of a CollectionJDK does not support any direct implementation of this interface; it provides more specific subinterface (List a ...

Posted by geroido on Fri, 17 Sep 2021 04:46:42 -0700

Spring dependency injection XML based DI

DI: assign values to attributes spring calls the parameterless construction method of the class to create an object. Assign a value to the property after the object is created. To assign a value to an attribute, you can use: Tags and attributes in xml configuration filesUsing annotations DI classification: Set injection is also called set ...

Posted by fatmart on Wed, 08 Sep 2021 15:01:00 -0700