Java multi-thread series-framework of "JUC set" 01

Source: Internet
Author: User

The Java Collection Package introduces the architecture of the Java Collection in the "overall framework of java Collection series 01. The body content includes Collection sets and Map classes, while Collection sets can be divided into List (Queue) and Set (Set ). 1. The List Implementation classes mainly include: Listing List, ArrayList, Vector, and Stack. (01) the queue list is a double-end queue implemented by a two-way linked list. It is not thread-safe and only applicable to a single thread. (02) ArrayList is an array-implemented queue. It is a dynamic array. It is not thread-safe and only applicable to single threads. (03) Vector is a Vector queue implemented by arrays. It is also a dynamic array. However, unlike ArrayList, Vector is thread-safe and supports concurrency. (04) Stack is implemented by Vector. Like Vector, Stack is thread-safe. 2. Set implementation classes include HastSet and TreeSet. (01) HashSet is a set of non-repeating elements implemented through HashMap. HashSet is NOT thread-safe and only applicable to single threads. (02) TreeSet is also a set of non-repeating elements, but unlike HashSet, the elements in TreeSet are ordered, implemented through TreeMap, and TreeSet is NOT thread-safe, only applicable to a single thread. 3. Map implementation classes include HashMap, WeakHashMap, Hashtable, and TreeMap. (01) HashMap is a hash table that stores "key-value pairs". It is not thread-safe and only applicable to single threads. (02) WeakHashMap is also a hash table. Unlike HashMap, the "key" of HashMap is a strongly referenced type, and WeakHashMap's "key" is a weak reference type, that is to say, when a key in WeakHashMap is no longer used normally, it will be automatically removed from WeakHashMap. WeakHashMap is NOT thread-safe and only applicable to a single thread. (03) Hashtable is also a hash table. Unlike HashMap, Hashtable is thread-safe and supports concurrency. (04) TreeMap is also a hash table, but the "key-Value Pair" in TreeMap is ordered, it is achieved through the R-B Tree (red and black Tree); TreeMap is NOT thread-safe, only applicable to a single thread.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.