Multi-thread data processing method, system and equipment based on blocking queue
A blocking queue and data processing technology, applied in the field of data processing, can solve the problem of low adaptability and achieve the effect of efficient and safe transmission
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0028] Please refer to figure 1 , the embodiment of the present invention provides a kind of method based on the multi-threaded data processing of blocking queue, comprises the following steps:
[0029] S101, creating a blocking queue;
[0030] Exemplarily, first you need to select the type of blocking queue, set the length and maximum capacity of the queue, and then you can create blocking queues, such as BlockingQueue, by introducing toolkits such as java.util.concurrent.BlockingQueue and LinkedBlockingQueue queue=new LinkedBlockingQueue (10). The capacity of this queue is 10.
[0031] S102, after the producer thread completes its own task, it is judged whether the capacity of the above-mentioned blocking queue has exceeded the preset capacity value, if so, then wait in line, if not, then insert data from the tail of the above-mentioned blocking queue;
[0032] After the blocking queue is created, each producer thread is started. After each producer thread completes ...
Embodiment 2
[0038] Specifically, if a user needs to make a loan, the bank will review his qualifications. With the consent of the user, the bank will separately query the user's bank statement, overdue information, and housing information, and then summarize and comprehensively give the user's quota based on these data . This scene is like figure 2 , at this time, the three query tasks are executed in parallel by multiple threads (that is, the producer thread), and the final consumer thread (that is, the consumer thread) needs to use the data of the three producer threads. At this time, this method can be used .
[0039] Specifically, the running process of each producer thread, such as image 3 As shown, specifically:
[0040] First, initialize and define the flag bit as TRUE, and enter the producer thread; perform the work of the producer itself, such as checking the bank flow; put the result of the flow information into the queue; judge whether the queue capacity exceeds 10...
Embodiment 3
[0044] Please refer to Figure 5 , some embodiments of the present invention provide a system for multi-threaded data processing based on blocking queues, queue creation module 100: for creating blocking queues; first judging module 200: for judging the above-mentioned Whether the capacity of the blocking queue exceeds the preset capacity value, if so, wait in line, if not, then insert data from the tail of the blocking queue; the second judging module 300: used to judge whether the queue is empty, if so, block the consumer thread ; If not, make the consumer thread ring obtain data from the head of the above-mentioned blocking queue; obtaining module 400: used for the consumer thread to obtain data.
[0045] Wherein, the first judging module 200 includes: a first execution unit 201, configured to execute queue waiting operations when the capacity of the blocking queue exceeds a preset capacity value; When the capacity value is preset, the operation of inserting data from...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com