In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1.ConcurrentModificationException
The reason for this is that the elements in the container are modified while traversing (iterator or enhanced loop) the synchronization class container, which can be solved with a normal for loop. Because a normal for loop is a thread operation.
two。 If a normal container wants to become a thread-safe container, it can be done with the Collections.synchronizedCollection method.
The 3.concurrentHashMap is divided into 16 segment slices, which calculates the volitile modification used in the size, while the value, and assignment, is to add a lock in each segment and no lock between the segment.
4.copyonwrite is copied in the data of the original thread every time a write operation is performed. After the operation is completed, the newly modified data will be assigned back, which is not suitable for scenarios with more list elements. When modified at the same time, there is a lock.
5. Various queues, blocking queues, non-blocking queues and × × queues, bounded queues. × × queue, add and offer have the same function. Blocking queue, the exception is not reported when add is added, and false is returned if offer is not added, or the waiting time can be set. The put method blocks right there. The poll method returns if it has a value from the opponent, and the substance returns a failure. The take method, when it has no value, blocks there until it has a value. DrainTo, one-time acquisition of multiple elements to improve efficiency.
6.concurrentLinkQueue is based on non-blocking × × queue, poll, value removal, peek, and values are not removed.
7.ArrayBlockingQueue is based on blocking bounded queues.
8.linkedblockingqueue blocks the queue.
9.SynchronousQueue cannot prevent blocking queues of any elements.
10.ProrityBlockingQueue, when adding, there is a dichotomy algorithm, and when taking a value, there is a comparison algorithm to take out the one with the highest priority.
11.DelayQueue has getDelay method and compareTo method, which are used to set delay time and compare and sort elements.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.