Home  >  Article  >  Java  >  Java Collection Framework Explanation Part 1

Java Collection Framework Explanation Part 1

巴扎黑
巴扎黑Original
2017-07-23 13:47:041326browse

1. Introduction to Collection

1. Concept: Collection is the most basic collection interface. A Collection represents a group of Objects, that is, the elements of the Collection. Some Collections allow identical elements and others do not. Some can be sorted but others cannot, so two subclass interfaces, List and Set, are derived.

2. Understand Collection intuitively through the map

2. Introduction to Map

1. Concept: map is a key value A collection of pairs of forms. Its elements are composed of keys and values. The key of the Map is unique and the value can be repeated.

2. Understand the Map intuitively through the map

3. The above mentioned many times about thread safety and non-thread safety, let’s make a simple Introduction:

1. Thread safety:

 When multiple thread classes concurrently operate a method of a certain class, (inside the method) If there is no error in modifying the value of a member variable of this class, then we say that this method is thread-safe.

The key to whether a method of a certain class is thread-safe is:

(1) Whether the method modifies the member variables of the class;

 (2) Whether to lock the method (whether to modify it with the synchronized keyword).

2. Thread unsafe:

 When multiple thread classes concurrently operate a method of a certain class, (inside the method) To modify the value of a member variable of this class, errors will easily occur, so we say that this method is thread-unsafe. If you want to make this method thread-safe, just use the synchronized keyword to modify the method.

The above is the detailed content of Java Collection Framework Explanation Part 1. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn