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

Pending Publication Date: 2022-03-29
SICHUAN XW BANK CO LTD
View PDF0 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

The other is the CountDownLatch class, which is implemented by means of a counter. The initial value of the counter is the number of threads. Whenever a thread is executed, the counter is decremented by 1. When the counter value is 0, it means that all threads are executed. The method needs to know the number of producer threads, and is only applicable to many-to-one, with low adaptability

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Multi-thread data processing method, system and equipment based on blocking queue
  • Multi-thread data processing method, system and equipment based on blocking queue
  • Multi-thread data processing method, system and equipment based on blocking queue

Examples

Experimental program
Comparison scheme
Effect test

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...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention relates to the technical field of data processing, in particular to a multi-thread data processing method, system and equipment based on a blocking queue. The invention discloses a multi-thread data processing method based on a blocking queue. The method comprises the following steps: creating the blocking queue; after the producer thread completes the task, judging whether the capacity of the blocking queue reaches a preset capacity value or not, if so, queuing for waiting, and if not, inserting data from the tail part of the blocking queue; whether the queue is empty or not is judged, and if yes, the consumer thread is blocked; if not, enabling the consumer thread ring to obtain data from the header of the blocking queue; and after the consumer thread obtains all the data, performing a task of the consumer thread. According to the method, the burden of the CPU can be reduced, and the adaptability to the number of threads in the data transmission process is improved. And meanwhile, under the condition that data depends on multiple threads, efficient and safe transmission of the data can be ensured, so that great convenience is brought to rapid establishment of a high-quality multi-thread program.

Description

technical field [0001] The present invention relates to the technical field of data processing, in particular to a blocking queue-based multi-threaded data processing method, system and equipment. Background technique [0002] The existing methods for dealing with multi-threaded data dependencies can be roughly divided into two categories, one is cyclic reading, each producer thread instance has an initial state, and changes the state after execution is completed, and there is a List in the consumer thread class to use To record all producer threads, the producer thread will be added to the List after each creation. After all producer threads are created, start all producer threads through the start method of the consumer thread, and traverse the status of all producer threads in the List through a while loop to determine whether all producer threads are executed, and if so, continue to execute Consuming threads, this method will use multiple while loops, which will increas...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/50G06F9/48
CPCG06F9/5038G06F9/505G06F9/4881
Inventor 徐烨辰杨嘉罗韬
Owner SICHUAN XW BANK CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products