Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the advanced features of Java

Shulou Source: shulou.com Published: 2022-06-01 05:13:26 10月01日 Update

This article introduces the relevant knowledge of "what are the advanced features of Java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1List and Set

The List and Set implementation classes in the JUC (java.util.concurrent) collection package include:

CopyOnWriteArrayList

CopyOnWriteArraySet

ConcurrentSkipListSet

ConcurrentSkipListSet will explain later when explaining Map.

The framework of CopyOnWriteArrayList and CopyOnWriteArraySet is shown in the following figure:

CopyOnWriteArrayList is the equivalent of thread-safe ArrayList, which implements the List interface. CopyOnWriteArrayList supports high concurrency.

CopyOnWriteArraySet is the equivalent of thread-safe HashSet, which inherits from the AbstractSet class.

CopyOnWriteArraySet contains a CopyOnWriteArrayList object internally, which is implemented through CopyOnWriteArrayList.

2Map

The implementation classes of Map in the JUC collection package include: ConcurrentHashMap and ConcurrentSkipListMap. Their framework is shown in the following figure:

ConcurrentHashMap is a thread-safe hash table (equivalent to thread-safe HashMap); it inherits from the AbstractMap class and implements the ConcurrentMap interface. ConcurrentHashMap is implemented through "lock segmentation", which supports concurrency.

ConcurrentSkipListMap is a thread-safe, ordered hash table (equivalent to thread-safe TreeMap); it inherits from the AbstractMap class and implements the ConcurrentNavigableMap interface. ConcurrentSkipListMap is implemented through a "jump table", which supports concurrency.

ConcurrentSkipListSet is an ordered collection of thread-safe (equivalent to thread-safe TreeSet); it inherits from AbstractSet and implements the NavigableSet interface. ConcurrentSkipListSet is implemented through ConcurrentSkipListMap, which also supports concurrency.

3Queue

The implementation classes of Queue in the JUC collection package include: ArrayBlockingQueue, LinkedBlockingQueue, LinkedBlockingDeque, ConcurrentLinkedQueue and ConcurrentLinkedDeque. Their framework is shown in the following figure:

ArrayBlockingQueue is a thread-safe, bounded blocking queue implemented by an array.

LinkedBlockingQueue is a (specified size) blocking queue implemented by an one-way linked list, which sorts elements by FIFO (first in first out).

LinkedBlockingDeque is a bi-directional concurrent blocking queue implemented by a bi-directional linked list (of a specified size), which supports both FIFO and FILO operations.

ConcurrentLinkedQueue is an unbounded queue implemented by an one-way linked list that sorts elements by FIFO (first in first out).

ConcurrentLinkedDeque is an unbounded queue implemented by a two-way linked list, which supports both FIFO and FILO operations.

This is the end of "what are the advanced features of Java"? thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Security threads queues support interfaces blocking two-way framework advanced features order elements advanced content one-way at the same time size way more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info Shulou Technology Xiaomi OPPO Reno