Parallel Processing Method, System, Electronic Device and Computer Readable Medium

The method ensures data consistency in distributed environments by comparing and matching database values across parallel threads, preventing conflicts and enabling fast delivery in ToB business scenarios.

CN113792056BActive Publication Date: 2025-07-15BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110060674.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-18
Publication Date
2025-07-15
Estimated Expiration
2041-01-18

AI Technical Summary

Technical Problem

Under the high concurrency business link, the isolated execution characteristics of concurrent threads in a distributed environment may lead to conflicts in concurrent execution results, which is difficult to effectively resolve in the existing technology.

Method used

Through the parallel processing method, each parallel thread receives data processing requests, reads the value of the target virtual account from the database as the first value, and after determining the parallel processing sub-result, reads the value in the database as the second value again, and changes the database according to the comparison results of the first value and the second value to ensure data consistency.

Benefits of technology

It effectively avoids the conflict of execution results between concurrent threads, ensures data consistency in a distributed environment, and meets the rapid delivery needs of ToB business construction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113792056B_ABST
    Figure CN113792056B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a parallel processing method, system, electronic device, and readable medium. The method includes: each parallel thread respectively receives a data processing request for a target virtual account; the parallel thread reads the value of the target virtual account from a database as a first value; after determining a parallel processing sub-result according to the first value, the parallel processing thread reads the value of the target virtual account from the database as a second value; in response to the data processing request, the parallel thread changes the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value. The parallel processing method, system, electronic device, and readable medium provided by the embodiments of the present disclosure can ensure data consistency in a distributed environment and avoid the phenomenon of concurrent execution result conflicts caused by the characteristics of concurrent threads executing in isolation from each other.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to a parallel processing method, system, electronic device, and computer-readable medium. Background Art

[0002] In the business construction scenarios for enterprises (To Business, ToB), concurrent business processing is often involved. In the high-concurrency business scenarios, the characteristics of concurrent threads executing independently of each other may cause conflicts in the concurrent execution results.

[0003] Therefore, a new parallel processing method, system, electronic device, and computer-readable medium are needed.

[0004] The above information disclosed in the Background Art section is only used to enhance the understanding of the background of the present disclosure, and thus it may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention

[0005] In view of this, embodiments of the present disclosure provide a parallel processing method, system, electronic device, and computer-readable medium, which can ensure data consistency in a distributed environment and avoid the phenomenon of conflicts in concurrent execution results caused by the characteristics of concurrent threads executing independently of each other.

[0006] Other features and advantages of the present disclosure will become apparent through the following detailed description, or will be partially learned through the practice of the present disclosure.

[0007] According to a first aspect of the embodiments of the present disclosure, a parallel processing method is proposed, which is applied to a parallel processing system. The parallel processing system includes multiple parallel threads. The method includes: each parallel thread respectively receives a data processing request for a target virtual account; the parallel thread reads the value of the target virtual account from the database as a first value; after the parallel processing thread determines a parallel processing sub-result according to the first value, it reads the value of the target virtual account from the database as a second value; in response to the data processing request, the parallel thread changes the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value.

[0008] In an exemplary embodiment of the present disclosure, in response to the data processing request, the parallel thread changing the second value in the database according to the parallel processing sub-result, the first value, and the second value includes: if the first value is equal to the second value, writing the parallel processing sub-result as the first value of the updated target virtual account into the database.

[0009] In an exemplary embodiment of the present disclosure, the method further includes: if the first value is different from the second value, determining that the parallel thread execution fails and retrying.

[0010] In an exemplary embodiment of the present disclosure, the data processing request includes a logical judgment task for a logical judgment object; the parallel processing thread determining a parallel processing sub-result according to the first value includes: the parallel thread executing the logical judgment task for the logical judgment object to obtain a logical judgment result; if the logical judgment result is passed, determining a target operation value according to the logical judgment result; and determining the parallel processing sub-result of the parallel thread according to the first value and the target operation value.

[0011] In an exemplary embodiment of the present disclosure, the parallel processing thread determining a parallel processing sub-result according to the first value further includes: if the logical judgment result is not passed, determining that the parallel processing sub-result of the parallel processing processor is failed.

[0012] In an exemplary embodiment of the present disclosure, the parallel thread changing the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value includes: if the parallel processing sub-result of the parallel thread is failed, stopping changing the value of the target virtual account in the database.

[0013] According to a second aspect of the embodiments of the present disclosure, a parallel processing system is provided, the system includes a plurality of parallel threads; the parallel threads are configured to respectively receive data processing requests for a target virtual account; read a first value of the target virtual account from a database; after determining a parallel processing sub-result according to the first value, read a second value of the target virtual account at the current moment from the database; and in response to the data processing request, change the second value in the database according to the parallel processing sub-result, the first value, and the second value.

[0014] In an exemplary embodiment of the present disclosure, when the parallel thread changes the second value in the database according to the parallel processing sub-result, the first value, and the second value in response to the data processing request, the parallel thread is configured to: if the first value is equal to the second value, write the parallel processing sub-result as the updated first value of the target virtual account into the database.

[0015] According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, which includes: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the parallel processing method described in any one of the above.

[0016] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the parallel processing method described in any one of the above is implemented.

[0017] According to the parallel processing method, system, electronic device and computer-readable medium provided by some embodiments of the present disclosure, in a parallel processing environment, when a parallel thread receives a data processing request, it reads the value of a target virtual account from a database as a first value, and during the process that a certain parallel processing thread determines a parallel processing sub-result according to the first value, since the value of the virtual resources of the target virtual account in the database may be changed by other parallel processing threads through write operations, the certain parallel processing thread reads the value of the target virtual account in the database again as a second value, and changes the value of the target virtual account in the database according to the comparison result of the first value and the second value. It can ensure data consistency in a distributed environment and avoid the phenomenon of concurrent execution result conflicts caused by the characteristics of isolated execution of concurrent threads with each other.

[0018] It should be understood that the above general description and the following detailed description are only exemplary and do not limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure. The following described accompanying drawings are only some embodiments of the present disclosure, and those of ordinary skill in the art can obtain other accompanying drawings based on these drawings without creative efforts.

[0020] Figure 1 is a system block diagram of a parallel processing method and apparatus shown according to an exemplary embodiment.

[0021] Figure 2 is a flowchart of a parallel processing method shown according to an exemplary embodiment.

[0022] Figure 3 is a flowchart of a parallel processing method shown according to an exemplary embodiment.

[0023] Figure 4It is a flowchart of a parallel processing method shown according to an exemplary embodiment.

[0024] Figure 5 It is a block diagram of a parallel processing system shown according to an exemplary embodiment.

[0025] Figure 6 A block diagram of an electronic device in an exemplary embodiment of the present disclosure is schematically shown. Detailed implementation manners

[0026] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. Identical reference numerals in the figures denote identical or similar parts, and thus their repetitive description will be omitted.

[0027] The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present invention. However, those skilled in the art will realize that the technical solutions of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the present invention.

[0028] The accompanying drawings are only schematic illustrations of the present invention, and identical reference numerals in the figures denote identical or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the drawings do not necessarily have to correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0029] The flowcharts shown in the accompanying drawings are only exemplary illustrations, not necessarily including all the content and steps, nor necessarily executed in the described order. For example, some steps can be decomposed, and some steps can be combined or partially combined, so the actual execution order may change according to the actual situation.

[0030] The example embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0031] Figure 1 It is a system block diagram of a parallel processing method and apparatus shown according to an exemplary embodiment.

[0032] Server 105 may be a server that provides various services, such as a background management server (merely for example) that supports a parallel processing system for operations performed by users using terminal devices 101, 102, and 103. The background management server may analyze and process data such as received parallel processing requests, and feedback the processing results (such as the change results of the target virtual account in the database - merely for example) to the terminal devices.

[0033] Server 105 may, for example, receive data processing requests for a target virtual account as separate parallel threads; the parallel threads read the value of the target virtual account from the database as a first value; after the parallel processing thread determines a parallel processing sub-result based on the first value, it reads the value of the target virtual account from the database as a second value; in response to the data processing request, the parallel thread changes the value of the target virtual account in the database based on the parallel processing sub-result, the first value, and the second value.

[0034] According to the parallel processing method and system provided by the embodiments of the present disclosure, in a parallel processing environment, when a parallel thread receives a data processing request, it reads the value of the target virtual account from the database as a first value, and during the process where a certain parallel processing thread determines a parallel processing sub-result based on the first value, since the value of the virtual resources of the target virtual account in the database may be changed by other parallel processing threads through write operations, the certain parallel processing thread reads the value of the target virtual account in the database again as a second value, and changes the value of the target virtual account in the database according to the comparison result of the first value and the second value. It can ensure data consistency in a distributed environment and avoid the phenomenon of concurrent execution result conflicts caused by the characteristics of isolated execution of concurrent threads with each other.

[0035] Figure 2 It is a flowchart of a parallel processing method shown according to an exemplary embodiment. The parallel processing method provided by the embodiments of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as terminal devices 101, 102, 103 and / or server 105. In the following embodiments, the server executing the method is taken as an example for illustration, but the present disclosure is not limited thereto. The parallel processing method provided by the embodiments of the present disclosure is applied to a parallel processing system, and the parallel processing system may include multiple parallel threads. The parallel processing method may include steps S202 to S208.

[0036] As Figure 2 shown, in step S202, each parallel thread respectively receives a data processing request for a target virtual account.

[0037] In the embodiments of the present disclosure, each parallel thread may separately receive different data processing requests for a target virtual account. For example, the data processing request may be triggered, for example, by an operation of a user associated with the target virtual account. The user associated with the target virtual account refers to a user whose operation will trigger a change in the virtual resource value in the target virtual account. Taking an online payment scenario as an example, when multiple users associated with the target virtual account trigger data processing requests for the target virtual account through operations, the multiple data processing requests may be separately received by each parallel thread.

[0038] In step S204, the parallel thread reads the first value of the target virtual account from the database.

[0039] In the embodiments of the present disclosure, the first value of the target virtual account may be stored in the database. In an online payment scenario, the first value of the target virtual account may be the quantity of virtual resources held by the user associated with the target virtual account.

[0040] In step S206, after the parallel processing thread determines the parallel processing sub-result according to the first value, it reads the second value of the target virtual account from the database.

[0041] In the embodiments of the present disclosure, during the process of the parallel processing thread determining the parallel processing sub-result, the virtual resource value corresponding to the target virtual account in the database may be changed after being written by other threads. Therefore, the second value may be different from the first value.

[0042] In an exemplary embodiment, the data processing request may include a logical judgment task for a logical judgment object. Among them, when the parallel processing thread determines the parallel processing sub-result according to the first value, the parallel thread may execute the logical judgment task for the logical judgment object to obtain a logical judgment result; if the logical judgment result is passed, the target operation value is determined according to the logical judgment result; the parallel processing sub-result of the parallel thread is determined according to the first value and the target operation value.

[0043] Among them, the logical judgment object may be the initial payment price in an online payment scenario, such as but not limited to the price of medicine, hospitalization expenses, pathological examination expenses, etc. The logical judgment task may be whether to meet the full reduction, discount, whether to use a coupon, etc. Different parallel threads may be used to execute different logical judgment tasks. For example, when it is considered that the current medicine meets the full reduction during the execution of the logical judgment task, it may be considered that the logical judgment result is passed, otherwise it is not passed. When the logical judgment result is passed, the final price (i.e., the target operation value) may be determined according to the medicine price and the full reduction activity, and the parallel processing sub-result is determined according to the difference between the first value and the final price (i.e., the target operation value). For example, the parallel processing sub-result may be used as the remaining quantity of virtual resources in the target virtual account after the final selling price of the medicine is paid.

[0044] In an exemplary embodiment, when the logical judgment result fails, it is determined that the parallel processing sub-result of the parallel processing processor fails.

[0045] In step S208, in response to the data processing request, the parallel thread changes the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value.

[0046] According to the parallel processing method provided by the embodiments of the present disclosure, in a parallel processing environment, when a parallel thread receives a data processing request, it reads the value of the target virtual account from the database as the first value. During the process that a certain parallel processing thread determines the parallel processing sub-result according to the first value, since the value of the virtual resource of the target virtual account in the database may be changed by other parallel processing threads through write operations, the certain parallel processing thread reads the value of the target virtual account in the database again as the second value, and changes the value of the target virtual account in the database according to the comparison result of the first value and the second value. It can ensure data consistency in a distributed environment and avoid the phenomenon of concurrent execution result conflicts caused by the characteristics of isolated execution of concurrent threads with each other.

[0047] In an exemplary embodiment, in step S208, if the first value is equal to the second value, the parallel processing sub-result can be written into the database as the updated value of the target virtual account.

[0048] Among them, if the first value is equal to the second value, it can be determined that during the process that the parallel thread determines the parallel processing sub-result according to the first value, no other parallel thread has performed a write operation on the value of the target virtual account in the database. Therefore, it can be determined that there is no phenomenon of concurrent execution result conflict, and the parallel processing sub-result of the certain parallel thread can be directly written into the database. If the first value is different from the second value, it is determined that the parallel thread execution fails and retries. In this embodiment, only based on the comparison of the first value and the second value, the phenomenon of concurrent execution result conflict can be avoided, and it can meet the rapid delivery of ToB business construction.

[0049] For another example, if the parallel processing sub-result of the parallel thread fails, the change to the value of the target virtual account in the database is stopped.

[0050] Figure 3 It is a flowchart of a parallel processing method shown according to an exemplary embodiment. The parallel processing method 30 provided by the embodiments of the present disclosure may include steps S302 to S306.

[0051] In an embodiment of the present disclosure, a deduction service for purchasing drugs is executed by one of multiple parallel threads. In the process of purchasing drugs, the balance of the patient's account needs to be queried and modified according to the drug price. The general business process includes the following steps.

[0052] As Figure 3 shown, in step S302, the existing balance of the user ($old_money = 100) is queried from the database according to the user primary key ($user_id). Among them, the existing balance is the value of the target virtual account read from the database, that is, the first value.

[0053] In step S304, the business layer calculates the logical judgment tasks of the business according to actual needs. The logical judgment tasks can be, for example: whether there is a discount, whether there is a full reduction.

[0054] a) If the drug has a discount (assumed to be 20% off), then the parallel processing sub-result $new_money = $old_money - drug price * 80% is used as the final actual balance after the user purchases the drug.

[0055] b) If a full reduction is required (assumed to be a full reduction of 20), then the parallel processing sub-result $new_money = $old_money - (drug price - 20) is used as the final actual balance after the user purchases the drug.

[0056] In step S306, the value of the target virtual account in the database is updated to the final actual balance, and the obtained result is updated and written into the database. As Figure 3 shown, assuming that the parallel processing sub-result obtained after executing the logical judgment task is 80, then the parallel processing sub-result can be used as the updated value of the updated target virtual account.

[0057] In the case of low concurrency Figure 3 the solution shown in the figure is okay, but as the concurrency increases, the problem of data inconsistency will occur. The reasons for concurrent conflicts are illustrated by the following examples.

[0058] Taking Figure 3 the business scenario mentioned as an example, when multiple patients related to the target virtual account purchase drugs, three logical judgment tasks are triggered simultaneously in a distributed environment. For example: 1. Logical judgment task A has a 20% discount; 2. Logical judgment task B has a full reduction activity, a full reduction of 10 for every 100; 3. Logical judgment task C has a coupon of 30 yuan. As Figure 4 shown, assume that the parallel processing sub-result of logical judgment task A is 80 (the drug price after discount is 20 yuan), the parallel processing sub-result of logical judgment task B is 90 (the drug price after discount is 10 yuan), and the parallel processing sub-result of logical judgment task C is 70 (the drug price after discount is 30 yuan).

[0059] Since the balances of the target virtual accounts in the database are all found to be 100 ($old_money = 100) by the above three deduction logics, at this time, the three logic judgment tasks simultaneously perform modification operations on the database balance. Then, the parallel processing sub-result of the last executed logic judgment task will be the final result stored in the database.

[0060] Suppose that logic judgment task C generates the parallel processing sub-result latest. Then, the balance of the target virtual account in the database is 70 yuan finally.

[0061] However, in the actual business scenario, after the above three deduction processes are executed, the balance of the patient should be 40 yuan (100 - 20 - 10 - 30 = 40). Therefore, the parallel execution of the above logic judgment tasks A, B, and C will lead to data writing conflict phenomena.

[0062] According to the parallel processing method of the present disclosure embodiment, as Figure 4 shown, the data consistency under concurrent request conditions can be ensured through the following execution steps.

[0063] Step S402, the first parallel thread executes logic judgment task A, queries the value of the target virtual account in the database (i.e., the first value: old_money = 100). After executing logic judgment task A, the parallel processing sub-result is calculated (new_money = 100 - 20 = 80). After logic judgment task A, compare whether the value of the target virtual account in the database (i.e., the second value) is equal to the first value 100. If the judgment result is consistent, then perform the modification.

[0064] Step S404, the second parallel thread executes logic judgment task B, queries the balance of the target virtual account in the database (i.e., the first value: old_money = 100). After executing logic judgment task B, the parallel processing sub-result is calculated (new_money = 100 - 10 = 90). After executing logic judgment task B, compare whether the value of the target virtual account in the database (i.e., the second value) is equal to the first value 100. It is found that the balance in the database has been modified to 80 by step S402 at this time, so the update is not executed, and a failure is returned, and the retry is executed.

[0065] Step S406, the third parallel thread executes logic judgment task C, queries the balance of the target virtual account in the database (i.e., the first value: old_money = 100). After executing logic judgment task C, the parallel processing sub-result is calculated (new_money = 100 - 30 = 70). After executing logic judgment task C, compare whether the value of the target virtual account in the database (i.e., the second value) is equal to the first value 100. It is found that the balance in the database has been modified to 80 by the first step at this time, so the update is not executed, and a failure is returned, and the retry is executed.

[0066] Step S408: When the second parallel thread retries the logical judgment task B, it rereads the balance of the target virtual account in the database (i.e., the first value: old_money = 80), executes the logical judgment task B, and calculates the parallel processing sub-result (new_money = 80 - 10 = 70). After executing the logical judgment task B, compare whether the value of the target virtual account in the database (i.e., the second value) is equal to the first value 80. If the judgment result is consistent, then execute the modification.

[0067] Step S410: When the third parallel thread retries the logical judgment task C, it rereads the balance of the target virtual account in the database (i.e., the first value: old_money = 70), executes the logical judgment task C, and calculates the parallel processing sub-result (new_money = 70 - 30 = 40). After executing the logical judgment task C, compare whether the value of the target virtual account in the database (i.e., the second value) is equal to the first value 70. If the judgment result is consistent, then execute the modification.

[0068] After the above steps, the final value of the target virtual account is 40, which can ensure the consistency of data in the database under high concurrency. In this embodiment, only by comparing the first value and the second value, the phenomenon of concurrent execution result conflicts can be avoided, and the rapid delivery of the ToB business construction can be satisfied.

[0069] It should be clearly understood that the present disclosure describes how to form and use specific examples, but the principles of the present disclosure are not limited to any details of these examples. On the contrary, based on the teachings of the content disclosed in the present disclosure, these principles can be applied to many other embodiments.

[0070] Those skilled in the art can understand that all or part of the steps of implementing the above embodiments are implemented as a computer program executed by a central processing unit (CPU). When the computer program is executed by the central processing unit CPU, the above functions defined by the above method provided by the present disclosure are executed. The program can be stored in a computer-readable storage medium, which can be a read-only memory, a magnetic disk or an optical disc, etc.

[0071] In addition, it should be noted that the above drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, rather than for limiting purposes. It is easy to understand that the processes shown in the above drawings do not indicate or limit the time sequence of these processes. Additionally, it is also easy to understand that these processes can be executed, for example, synchronously or asynchronously in multiple modules.

[0072] The following are embodiments of the present disclosure system, which can be used to execute the method embodiments of the present disclosure. For details not disclosed in the system embodiments of the present disclosure, please refer to the method embodiments of the present disclosure.

[0073] Figure 5 is a block diagram of a parallel processing system shown according to an exemplary embodiment. Referring to Figure 5 , the parallel processing system 50 provided by the embodiments of the present disclosure may include: a plurality of parallel threads 502.

[0074] In the parallel processing system 50, each parallel thread 502 can be configured to respectively receive a data processing request for a target virtual account; read a first value of the target virtual account from a database; after determining a parallel processing sub-result according to the first value, read a second value of the target virtual account at the current moment from the database; and in response to the data processing request, change the second value in the database according to the parallel processing sub-result, the first value, and the second value.

[0075] According to the parallel processing system provided by the embodiments of the present disclosure, in a parallel processing environment, when a parallel thread receives a data processing request, it reads the value of the target virtual account from the database as the first value, and during the process that a certain parallel processing thread determines the parallel processing sub-result according to the first value, since the value of the virtual resources of the target virtual account in the database may be changed by other parallel processing threads through write operations, the certain parallel processing thread reads the value of the target virtual account in the database again as the second value, and changes the value of the target virtual account in the database according to the comparison result of the first value and the second value. It can ensure data consistency in a distributed environment and avoid the phenomenon of concurrent execution result conflicts caused by the characteristics of concurrent threads executing in isolation from each other.

[0076] In an exemplary embodiment, when the parallel thread 502 changes the second value in the database according to the parallel processing sub-result, the first value, and the second value in response to the data processing request, the parallel thread 502 can be configured to write the parallel processing sub-result as the updated first value of the target virtual account into the database if the first value is equal to the second value. In this embodiment, only by comparing the first value with the second value, the phenomenon of concurrent execution result conflicts can be avoided, and the rapid delivery of the ToB business construction can be satisfied.

[0077] Next, referring to Figure 6 to describe the electronic device 600 according to this embodiment of the present invention. Figure 6 The electronic device 600 shown is only an example and should not bring any limitations to the functions and usage scopes of the embodiments of the present invention.

[0078] As Figure 6As shown, the electronic device 600 is presented in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one of the above-mentioned processing units 610, at least one of the above-mentioned storage units 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).

[0079] Among them, the storage unit stores program code, and the program code can be executed by the processing unit 610, so that the processing unit 610 executes the steps according to various exemplary embodiments of the present invention described in the "Exemplary Method" section of this specification. For example, the processing unit 610 can execute steps such as Figure 1 shown in, step S202, each parallel thread respectively receives a data processing request for a target virtual account; step S204, the parallel thread reads the first value of the target virtual account from the database; step S206, after the parallel processing thread determines the parallel processing sub-result according to the first value, reads the second value of the target virtual account from the database; step S208, in response to the data processing request, the parallel thread changes the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value.

[0080] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 6201 and / or a cache storage unit 6202, and may further include a read-only storage unit (ROM) 6203.

[0081] The storage unit 620 may further include a program / utilities 6204 having a set (at least one) of program modules 6205. Such program modules 6205 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment.

[0082] The bus 630 may represent one or more of several types of bus structures, including a storage unit bus or a storage unit controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any bus structure in a variety of bus structures.

[0083] The electronic device 600 can also communicate with one or more external devices 700 (such as a keyboard, a pointing device, a Bluetooth device, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication can be carried out through the input / output (I / O) interface 650. Moreover, the electronic device 600 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 660. As shown in the figure, the network adapter 660 communicates with other modules of the electronic device 600 through the bus 630. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0084] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software, or can be implemented by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.

[0085] In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium, on which a program product capable of implementing the above methods of this specification is stored. In some possible implementation manners, various aspects of the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "exemplary method" section of this specification.

[0086] The program product may adopt any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0087] The computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries the readable program code. Such a propagated data signal may take various forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable signal medium may also be any readable medium other than the readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0088] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination of the above.

[0089] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., by connecting through the Internet service provider via the Internet).

[0090] In addition, the above drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present invention, rather than for limiting purposes. It is easy to understand that the processes shown in the above drawings do not indicate or limit the chronological order of these processes. Additionally, it is also easy to understand that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0091] Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and examples are only to be considered as exemplary, and the true scope and concept of the present disclosure are pointed out by the claims.

Claims

1. A parallel processing method, characterized in that, Applied to a parallel processing system, the parallel processing system including a plurality of parallel threads, the method comprising: Each parallel thread respectively receives a data processing request for a target virtual account; The parallel thread reads the value of the target virtual account from a database as a first value; After the parallel thread determines a parallel processing sub-result according to the first value, it reads the value of the target virtual account from the database as a second value; In response to the data processing request, the parallel thread changes the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value, which includes: if the first value is equal to the second value, writing the parallel processing sub-result as the updated first value of the target virtual account into the database; if the first value is different from the second value, determining that the parallel thread execution fails and retrying.

2. The method according to claim 1, wherein The data processing request includes a logical judgment task for a logical judgment object; The parallel thread determining a parallel processing sub-result according to the first value includes: The parallel thread executes the logical judgment task for the logical judgment object to obtain a logical judgment result; If the logical judgment result is passed, determining a target operation value according to the logical judgment result; Determining the parallel processing sub-result of the parallel thread according to the first value and the target operation value.

3. The method according to claim 2, characterized in that, The parallel thread determining a parallel processing sub-result according to the first value further includes: If the logical judgment result is not passed, determining that the parallel processing sub-result of the parallel thread is a failure.

4. The method according to claim 3, characterized in that, The parallel thread changing the value of the target virtual account in the database according to the parallel processing sub-result, the first value, and the second value includes: If the parallel processing sub-result of the parallel thread is a failure, stopping changing the value of the target virtual account in the database.

5. A parallel processing system, characterized in that, Including a plurality of parallel threads; The parallel threads are configured to respectively receive data processing requests for a target virtual account; Reading a first value of the target virtual account from a database; after determining a parallel processing sub-result according to the first value, reading a second value of the target virtual account at the current moment from the database; and in response to the data processing request, changing the second value in the database according to the parallel processing sub-result, the first value, and the second value; When the parallel thread changes the second value in the database according to the parallel processing sub-result, the first value, and the second value in response to the data processing request, the parallel thread is configured to: if the first value is equal to the second value, write the parallel processing sub-result as the updated first value of the target virtual account into the database; if the first value is different from the second value, determining that the parallel thread execution fails and retrying.

6. An electronic device, characterized in that, Including: At least one processor; A storage device for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1-4.

7. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, the method according to any one of claims 1-4 is implemented.

Citation Information

Patent Citations

  • Hotspot account concurrent data processing system and method

    CN110298746A

  • Method and device for concurrently executing transactions in block chain

    CN110648124A