In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to add and fetch data in JUC ArrayBlockingQueue". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to add and fetch data with JUC ArrayBlockingQueue".
ArrayBlockingQueue has the following characteristics:
A bounded blocking queue implemented by an array. Once the capacity is created, the subsequent size cannot be modified.
In accordance with the first-in-first-out rule, the head of the team takes the data and the end of the team takes the data.
Like LinkedBlockingQueue, when the queue is full, the put data in the queue will be blocked. When the queue is empty, getting data to the queue will be blocked.
When you operate on data, you share a lock, so you can't read and write at the same time.
ArrayBlockingQueue, like LinkedBlockingQueue, also inherits AbstractQueue to implement the BlockingQueue interface, so it is the same as LinkedBlockingQueue in terms of methods, so instead of listing the methods here, we can check out the previous LinkedBlockingQueue article ~
In addition to methods, there are two more important parameters in ArrayBlockingQueue:
/ * * items index for next take, poll, peek or remove * /
/ / get the location of the element
Int takeIndex
/ * * items index for next put, offer, or add * /
/ / Array subscript when adding elements
Int putIndex
Since the bottom layer of ArrayBlockingQueue is an array, combined with the above two parameters, the overall structure of ArrayBlockingQueue is roughly as follows:
ArrayBlockingQueue has three constructors:
Public ArrayBlockingQueue (int capacity)
/ / fair indicates whether it is a fair lock
Public ArrayBlockingQueue (int capacity, boolean fair)
Public ArrayBlockingQueue (int capacity, boolean fair, Collection
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.