CN107861799B - Task processing method and device based on multi-thread environment - Google Patents
Task processing method and device based on multi-thread environment Download PDFInfo
- Publication number
- CN107861799B CN107861799B CN201611233918.6A CN201611233918A CN107861799B CN 107861799 B CN107861799 B CN 107861799B CN 201611233918 A CN201611233918 A CN 201611233918A CN 107861799 B CN107861799 B CN 107861799B
- Authority
- CN
- China
- Prior art keywords
- task
- service
- scheduling
- scheduling task
- key
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mobile Radio Communication Systems (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a task processing method based on a multithreading environment, which comprises the following steps: in the process of executing a scheduling task in a task list based on a multi-thread environment, when a thread starting scheduling task is detected, a service main key preset for the started scheduling task is read; putting the read service primary key into the established lock table; and acquiring a task object of the scheduling task according to the read service main key, and executing the scheduling task by the thread based on the task object. The invention also provides a task processing device based on the multithreading environment. The invention solves the technical problem that the same scheduling task is repeatedly executed by a plurality of threads in the prior art.
Description
Technical Field
The invention relates to the technical field of data processing, in particular to a task processing method and device based on a multi-thread environment.
Background
Because most of services in the industries such as insurance and finance have the characteristic of large data volume, service processing is often performed in a multi-thread concurrent mode, in the existing multi-thread environment, after a thread executes a scheduling task, the state of the scheduling task is marked as an executed state, but for the service with large data volume, more task objects may exist in one scheduling task or the processing period of one scheduling task is long, so that when the thread does not execute the scheduling task, the scheduling task is repeatedly executed by other threads.
For example, after the underwriting is completed, notification information, such as short message, mail, etc., needs to be sent to the insured person based on the contact information in the insured person information of the policy. In this service, each policy corresponds to a scheduling task, and a large amount of information of an insured person causes a long execution time of the scheduling task, which results in that a task object of the scheduling task, i.e. information of the insured person, is captured by other threads in a process of executing the scheduling task, i.e. acquiring the information of the insured person from the policy and sending notification information to the insured person, so that the scheduling task is repeatedly executed, the notification information is repeatedly sent, and further the efficiency of processing the service is low.
Disclosure of Invention
The invention provides a task processing method and a task processing device based on a multi-thread environment, and mainly aims to solve the technical problem that the same scheduling task is repeatedly executed by a plurality of threads in the prior art.
In order to achieve the above object, the present invention provides a task processing method based on a multithreading environment, including:
in the process of executing a scheduling task in a task list based on a multi-thread environment, when a thread starting scheduling task is detected, a service main key preset for the started scheduling task is read;
putting the read service primary key into the established lock table;
and acquiring a task object of the scheduling task according to the read service main key, and executing the scheduling task by the thread based on the task object.
Optionally, after the step of obtaining the task object of the scheduling task according to the read service key and executing the scheduling task by the thread based on the task object, the task processing method based on the multi-thread environment further includes the steps of:
and detecting the execution progress of the scheduling task, and releasing the service primary key in the lock table when the scheduling task is detected to be executed completely.
Optionally, after the step of reading a service key preset for the started scheduling task when it is detected that a thread starts the scheduling task, the task processing method based on the multi-thread environment further includes the steps of:
judging whether the service main key is read successfully or not;
if the service primary key is successfully read, the step of putting the read service primary key into the established lock table is executed;
and if the reading of the service main key fails, releasing the resources occupied by the scheduling task, starting the next scheduling task in the task list, and executing the step of reading the service main key preset for the started scheduling task.
Optionally, the task processing method based on the multithreading environment further includes the steps of:
acquiring the duration of the continuous locking of the service main key in the lock table in a timing manner;
and when detecting that the duration of the continuous locking of the service primary key in the lock table is longer than the preset duration, releasing the service primary key from the lock table.
Optionally, the task processing method based on the multithreading environment further includes the steps of:
and when the completion of the execution of the scheduling task is detected, marking the state of the scheduling task as a processed state.
In order to achieve the above object, the present invention provides a task processing apparatus based on a multithreading environment, including:
the system comprises a main key reading module, a task scheduling module and a task scheduling module, wherein the main key reading module is used for reading a service main key preset for a started scheduling task when a thread starts the scheduling task in the process of executing the scheduling task in a task list based on a multi-thread environment;
the primary key locking module is used for putting the read service primary key into the established lock table;
and the task execution module is used for acquiring the task object of the scheduling task according to the read service main key and executing the scheduling task by the thread based on the task object.
Optionally, the task processing apparatus based on the multithreading environment further includes:
and the primary key release module is used for detecting the execution progress of the scheduling task and releasing the service primary key in the lock list when detecting that the scheduling task is completely executed.
Optionally, the task processing apparatus based on the multithreading environment further includes:
the judging module is used for judging whether the service main key is read successfully or not;
the primary key lock module is further to: if the service primary key is successfully read, the read service primary key is put into an established lock table;
the task execution module is further configured to: and releasing resources occupied by the scheduling task, starting the next scheduling task in the task list, and executing and reading a service main key preset for the started scheduling task.
Optionally, the task processing apparatus based on the multithreading environment further includes:
the duration acquisition module is used for acquiring the duration of the continuous locking of the service main key in the lock list in a timing mode;
the primary key release module is further configured to: and when detecting that the duration of the continuous locking of the service primary key in the lock table is longer than the preset duration, releasing the service primary key from the lock table.
Optionally, the task processing apparatus based on the multithreading environment further includes:
and the state marking module is used for marking the state of the scheduling task as a processed state when the completion of the execution of the scheduling task is detected.
When the scheduling task in the task list is executed based on the multi-thread environment, when the fact that the thread starts the scheduling task is detected, the service main key of the started scheduling task is read, the read service main key is put into the established lock list, then the task object of the scheduling task is obtained according to the read service main key, the scheduling task is executed by the thread based on the task object, the thread cannot be read again for the service main key stored in the lock list, and the scheduling task corresponding to the service main key cannot be executed, so that the scheduling task in the task list can be prevented from being repeatedly executed by different threads, and the execution efficiency of the service is improved.
Drawings
FIG. 1 is a flowchart of a first embodiment of a task processing method based on a multi-thread environment according to the present invention;
FIG. 2 is a functional block diagram of a task processing device based on a multi-thread environment according to a first embodiment of the present invention;
FIG. 3 is a functional block diagram of another embodiment of a task processing device based on a multi-thread environment according to the present invention;
FIG. 4 is a functional block diagram of a task processing device based on a multi-thread environment according to a second embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a task processing method based on a multithreading environment. Referring to fig. 1, a flowchart of a first embodiment of a task processing method based on a multi-thread environment according to the present invention is shown.
In this embodiment, the task processing method based on the multithreading environment includes:
step S10, in the process of executing the scheduling task in the task list based on the multi-thread environment, when it is detected that the thread starts the scheduling task, reading a service key preset for the started scheduling task.
Step S20, the read service main key is put into the established lock table;
and step S30, acquiring the task object of the scheduling task according to the read service main key, and executing the scheduling task by the thread based on the task object.
In the embodiment of the invention, the scheduling tasks are executed based on the multithreading environment, the task list is established for the service to be processed, the task list comprises a plurality of scheduling tasks, a plurality of threads in the preset multithreading environment process the scheduling tasks in the task list together, and the threads execute the scheduling tasks according to the preset arrangement sequence for the scheduling tasks in the task list when processing the scheduling tasks in the task list. And when the task list is started, a lock table is established, the thread cannot read the service main key stored in the lock table, and further the scheduling task corresponding to the service main key cannot be executed. The number of the service primary keys of a scheduling task is not limited, and may be one or more.
When a thread starts a scheduling task, a service main key preset for the scheduling task is read first, if the reading is successful, the service main key of the scheduling task is not stored in a lock list, the thread can execute the scheduling task, if the reading is failed, the service main key of the scheduling task is in an unreadable state, other threads currently process the task, the scheduling task can be skipped directly, a next scheduling task in a task list is executed, and after the thread starts the scheduling task, certain resources are allocated to the scheduling task for the execution of the task, so that before the next scheduling task is executed, the resources occupied by the current scheduling task are released to avoid the waste of the resources.
Specifically, after step S10, the method for processing tasks based on a multithreading environment further includes:
judging whether the service main key is read successfully or not; if the service primary key is successfully read, the step of putting the read service primary key into the established lock table is executed; and if the reading of the service main key fails, releasing the resources occupied by the scheduling task, starting the next scheduling task in the task list, and executing the step of reading the service main key preset for the started scheduling task.
In this embodiment, when the thread successfully reads the service primary key, the service primary key is stored in the established lock table, then the task object of the scheduling task is obtained according to the service primary key, and the scheduling task is executed based on the obtained task object, further, during the process of executing the scheduling task, the execution progress of the scheduling task is detected in real time or at regular time, and when it is detected that the execution of the scheduling task is completed, the service primary key in the lock table is released; and when the completion of the execution of the scheduling task is detected, marking the state of the scheduling task as a processed state.
The method of this embodiment is described below by referring to a specific application scenario, taking a client notification service of a group policy in an insurance service as an example, where the group policy is a group insurance policy, and is an insurance policy with a number of insured persons being greater than a set number, where one insurance policy corresponds to one scheduling task, and each scheduling task needs to send notification information to all insured persons in the insurance policy.
In this embodiment, each scheduled task may include one or more preset service primary keys, where a service primary key may be a task object itself or service data associated with a task object, and if the service data is stored in the lock table as a service primary key, the thread may no longer obtain the task object associated with the service data. Specifically, the policy number in each scheduling task may be used as a service main key, and after the scheduling task is started, the thread needs to acquire the policy number corresponding to the task first, and then captures the required insured information from the policy corresponding to the acquired policy number. For the thread executing the scheduling task, when the scheduling task is started, the policy number is read, the read policy number is stored in the lock table, the insured person information is obtained from the policy, the notification information is sent to each insured person based on the obtained insured person information, and after the notification information is sent, the state of the scheduling task is modified into the executed state.
Or, in other embodiments, only part of the data that needs to be captured from the policy when executing the scheduling task is used as the business master key, that is, the task object is used as the business master key, for example, if the customer notification business of the policy requires to send short message notification information to the insured, when executing the scheduling task, the part of the data that needs to be obtained is the insured name and the mobile phone number in the insured information, and in general, the insured information in the policy contains information such as the insured name, the mobile phone number, the address, the certificate type and the certificate number, so in this business scenario, the insured name and the mobile phone number can be used as the preset business master key, when starting a scheduling task, the insured name and the mobile phone number in the policy of the scheduling task are put into the established lock table, for the policy, because there are a plurality of insured persons, the name and the mobile phone number of each insured person are required to be stored in the lock table as service main keys, even if other threads can read the policy number when starting the scheduling task, the name and the mobile phone number of the insured person required by the execution service cannot be read, so other threads still cannot execute the task; and when partial data is used as a service main key, other threads are not influenced to acquire other data in the policy.
It should be noted that the application scenarios are only examples, and the method of this embodiment is not limited to the business processing of the clique, and can be applied to business processing in any multi-thread environment.
According to the task processing method based on the multi-thread environment, when the scheduling task in the task list is executed based on the multi-thread environment, when the fact that the thread starts the scheduling task is detected, the service main key of the started scheduling task is read, the read service main key is placed into the established lock table, then the task object of the scheduling task is obtained according to the read service main key, the scheduling task is executed by the thread based on the task object, the thread cannot be read again for the service main key stored in the lock table, and therefore the scheduling task corresponding to the service main key cannot be executed, the scheduling task in the task list can be prevented from being executed repeatedly by different threads, and the execution efficiency of the service is improved.
The second embodiment of the task processing method based on the multithreading environment is provided based on the first embodiment. In this embodiment, the method for processing tasks based on a multi-thread environment further includes:
acquiring the duration of the continuous locking of the service main key in the lock table in a timing manner;
and when detecting that the duration of the continuous locking of the service primary key in the lock table is longer than the preset duration, releasing the service primary key from the lock table.
In this embodiment, the duration that the service primary key stored in the lock table is continuously locked is detected to avoid that the service primary key is locked for too long due to an abnormal execution of the scheduling task, for example, when the program terminates abnormally, the service primary key stored in the lock table is not released, and when the program restarts, all threads cannot successfully read the service primary key, and thus the corresponding scheduling task cannot be executed, in the manner of this embodiment, the duration that the service primary key in the lock table is continuously locked is detected, and when the duration that the service primary key is detected to be continuously locked is longer than the preset duration, the duration is released from the lock table to avoid that the scheduling task cannot be executed, where the preset duration may be set by the user according to a specific scheduling task, for example, by estimating the time required for executing the scheduling task under normal conditions, the preset duration is set to be greater than the time.
Further, as an embodiment, before step S10, the method for processing tasks based on a multi-thread environment further includes:
and when an input service main key selection instruction is received, taking a service parameter corresponding to the service main key selection instruction as a preset service main key.
In this embodiment, before executing a task in a task list based on a multi-thread environment, a service main key configuration interface may be provided for a user, so that the user configures a preset service main key for a scheduling task to be executed based on the configuration interface, all service parameters of a service corresponding to the scheduling task are displayed in the configuration interface, taking a policy as an example, all parameters in the policy are displayed, and the user may trigger a selection instruction based on any displayed parameter, for example, the user selects a credential number of an insured person in the policy as a service main key, and when the thread executes the scheduling task, the credential number of a specific insured person in the policy of the scheduling task needs to be stored in a lock table as the service main key. By the method of the embodiment, the user can flexibly configure the service main key for the service before starting the program to process the service.
The invention also provides a task processing device based on the multithreading environment.
Referring to fig. 2, a functional block diagram of a task processing device based on a multi-thread environment according to a first embodiment of the present invention is shown.
In this embodiment, the task processing apparatus based on a multithreading environment includes:
the main key reading module 10 is configured to, when it is detected that a thread starts a scheduling task in a process of executing the scheduling task in a task list based on a multi-thread environment, read a service main key preset for the started scheduling task.
And a primary key locking module 20, configured to put the read service primary key into the established lock table.
And the task execution module 30 is configured to obtain a task object of the scheduling task according to the read service key, and execute the scheduling task by the thread based on the task object.
In the embodiment of the invention, the scheduling tasks are executed based on the multithreading environment, the task list is established for the service to be processed, the task list comprises a plurality of scheduling tasks, a plurality of threads in the preset multithreading environment process the scheduling tasks in the task list together, and the threads execute the scheduling tasks according to the preset arrangement sequence for the scheduling tasks in the task list when processing the scheduling tasks in the task list. And when the task list is started, a lock table is established, the thread cannot read the service main key stored in the lock table, and further the scheduling task corresponding to the service main key cannot be executed. The number of the service primary keys of a scheduling task is not limited, and may be one or more.
When a thread starts a scheduling task, a service main key preset for the scheduling task is read first, if the reading is successful, the service main key of the scheduling task is not stored in a lock list, the thread can execute the scheduling task, if the reading is failed, the service main key of the scheduling task is in an unreadable state, other threads currently process the task, the scheduling task can be skipped directly, a next scheduling task in a task list is executed, and after the thread starts the scheduling task, certain resources are allocated to the scheduling task for the execution of the task, so that before the next scheduling task is executed, the resources occupied by the current scheduling task are released to avoid the waste of the resources.
Specifically, the task processing device based on the multithreading environment further comprises:
the judging module is used for judging whether the service main key is read successfully or not; the primary key lock module 20 is also configured to: if the service primary key is successfully read, the read service primary key is put into an established lock table; the task execution module 30 is further configured to: and releasing resources occupied by the scheduling task, starting the next scheduling task in the task list, and executing and reading a service main key preset for the started scheduling task.
In this embodiment, when the thread successfully reads the service primary key, the service primary key is stored in the established lock table, then the task object of the scheduling task is obtained according to the service primary key, and the scheduling task is executed based on the obtained task object, further, as shown in fig. 3, as an implementation manner, the task processing apparatus based on the multithreading environment further includes:
and the primary key release module 40 is configured to detect an execution progress of the scheduling task, and release the service primary key in the lock table when it is detected that the scheduling task is completely executed. And in the process of executing the scheduling task, detecting the execution progress of the scheduling task in real time or at regular time, and releasing the service primary key in the lock table when the completion of the execution of the scheduling task is detected.
Further, the task processing device based on the multithreading environment further comprises:
and the state marking module is used for marking the state of the scheduling task as a processed state when the completion of the execution of the scheduling task is detected.
The following describes this embodiment by taking a specific application scenario, and taking a client notification service of a policy in an insurance service as an example, where the policy, i.e. a group insurance policy, is a policy with a number of insured persons greater than a set number, where one policy corresponds to one scheduling task, and each scheduling task needs to send notification information to all insured persons in the policy.
In this embodiment, each scheduled task may include one or more preset service primary keys, where a service primary key may be a task object itself or service data associated with a task object, and if the service data is stored in the lock table as a service primary key, the thread may no longer obtain the task object associated with the service data. Specifically, the policy number in each scheduling task may be used as a service main key, and after the scheduling task is started, the thread needs to acquire the policy number corresponding to the task first, and then captures the required insured information from the policy corresponding to the acquired policy number. For the thread executing the scheduling task, when the scheduling task is started, the policy number is read, the read policy number is stored in the lock table, the insured person information is obtained from the policy, the notification information is sent to each insured person based on the obtained insured person information, and after the notification information is sent, the state of the scheduling task is modified into the executed state.
Or, in other embodiments, only part of the data that needs to be captured from the policy when executing the scheduling task is used as the business master key, that is, the task object is used as the business master key, for example, if the customer notification business of the policy requires to send short message notification information to the insured, when executing the scheduling task, the part of the data that needs to be obtained is the insured name and the mobile phone number in the insured information, and in general, the insured information in the policy contains information such as the insured name, the mobile phone number, the address, the certificate type and the certificate number, so in this business scenario, the insured name and the mobile phone number can be used as the preset business master key, when starting a scheduling task, the insured name and the mobile phone number in the policy of the scheduling task are put into the established lock table, for the policy, because there are a plurality of insured persons, the name and the mobile phone number of each insured person are required to be stored in the lock table as service main keys, even if other threads can read the policy number when starting the scheduling task, the name and the mobile phone number of the insured person required by the execution service cannot be read, so other threads still cannot execute the task; and when partial data is used as a service main key, other threads are not influenced to acquire other data in the policy.
It should be noted that the above application scenarios are only examples, and the apparatus of this embodiment is not limited to the business processing of the clique, and may be applied to business processing in any multi-thread environment.
The task processing device based on the multi-thread environment provided by this embodiment reads a service main key of a started scheduling task when a thread starts the scheduling task when executing the scheduling task in a task list based on the multi-thread environment, places the read service main key into an established lock table, then obtains a task object of the scheduling task according to the read service main key, and executes the scheduling task based on the task object by the thread.
The second embodiment of the task processing device based on the multithreading environment of the present invention is proposed based on the first embodiment. Referring to fig. 4, in this embodiment, the task processing apparatus based on a multithread environment further includes:
a duration obtaining module 50, configured to obtain, in a timing manner, a duration for which a service primary key in the lock table is continuously locked;
the primary key release module 40 is further configured to: and when detecting that the duration of the continuous locking of the service primary key in the lock table is longer than the preset duration, releasing the service primary key from the lock table.
In this embodiment, the duration that the service primary key stored in the lock table is continuously locked is detected to avoid that the service primary key is locked for too long due to an abnormal execution of the scheduling task, for example, when the program terminates abnormally, the service primary key stored in the lock table is not released, and when the program restarts, all threads cannot successfully read the service primary key, and thus the corresponding scheduling task cannot be executed, in the manner of this embodiment, the duration that the service primary key in the lock table is continuously locked is detected, and when the duration that the service primary key is detected to be continuously locked is longer than the preset duration, the duration is released from the lock table to avoid that the scheduling task cannot be executed, where the preset duration may be set by the user according to a specific scheduling task, for example, by estimating the time required for executing the scheduling task under normal conditions, the preset duration is set to be greater than the time.
Further, the task processing device based on the multithreading environment further comprises:
and the main key setting module is used for taking the service parameter corresponding to the service main key selection instruction as a preset service main key when receiving the input service main key selection instruction.
In this embodiment, before executing a task in a task list based on a multi-thread environment, a service main key configuration interface may be provided for a user, so that the user configures a preset service main key for a scheduling task to be executed based on the configuration interface, all service parameters of a service corresponding to the scheduling task are displayed in the configuration interface, taking a policy as an example, all parameters in the policy are displayed, and the user may trigger a selection instruction based on any displayed parameter, for example, the user selects a credential number of an insured person in the policy as a service main key, and when the thread executes the scheduling task, the credential number of a specific insured person in the policy of the scheduling task needs to be stored in a lock table as the service main key. By the device of the embodiment, the user can flexibly configure the service main key for the service before starting the program to process the service.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention or portions thereof that contribute to the prior art may be embodied in the form of a software product, where the computer software product is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk), and includes several instructions for enabling a terminal device (e.g., a mobile phone, a computer, a cloud server, or a network device) to execute the method according to the embodiments of the present invention.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In addition, descriptions related to "first", "second", and the like in the present invention are for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicit indication of the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions in the embodiments may be combined with each other, but it must be based on the realization of those skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should be considered to be absent and not within the protection scope of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (8)
1. A task processing method based on a multithreading environment is characterized by comprising the following steps:
in the process of executing a scheduling task in a task list based on a multi-thread environment, when a thread is detected to start the scheduling task, reading a service main key preset for the started scheduling task, wherein the service main key is a task object or service data associated with the task object;
putting the read service primary key into the established lock table;
acquiring a task object of the scheduling task according to the read service main key, and executing the scheduling task by the thread based on the task object;
after the step of reading a service main key preset for the started scheduling task when the thread starts the scheduling task is detected, the task processing method based on the multithreading environment further comprises the following steps:
judging whether the service main key is read successfully or not;
if the service primary key is successfully read, the step of putting the read service primary key into the established lock table is executed;
and if the reading of the service main key fails, releasing the resources occupied by the scheduling task, starting the next scheduling task in the task list, and executing the step of reading the service main key preset for the started scheduling task.
2. The task processing method based on the multi-thread environment according to claim 1, wherein after the step of obtaining the task object of the scheduling task according to the read service key and executing the scheduling task by the thread based on the task object, the task processing method based on the multi-thread environment further comprises the steps of:
and detecting the execution progress of the scheduling task, and releasing the service primary key in the lock table when the scheduling task is detected to be executed completely.
3. The multithreading environment-based task processing method of claim 1, further comprising the steps of:
acquiring the duration of the continuous locking of the service main key in the lock table in a timing manner;
and when detecting that the duration of the continuous locking of the service primary key in the lock table is longer than the preset duration, releasing the service primary key from the lock table.
4. A method for task processing based on a multi-thread environment according to any one of claims 1 to 3, further comprising the steps of:
and when the completion of the execution of the scheduling task is detected, marking the state of the scheduling task as a processed state.
5. A task processing apparatus based on a multithreading environment, the task processing apparatus based on a multithreading environment comprising:
the system comprises a main key reading module, a task scheduling module and a task execution module, wherein the main key reading module is used for reading a service main key preset for a started scheduling task when a thread starts the scheduling task in the process of executing the scheduling task in a task list based on a multi-thread environment, and the service main key is a task object or service data associated with the task object;
the primary key locking module is used for putting the read service primary key into the established lock table;
the task execution module is used for acquiring a task object of the scheduling task according to the read service main key and executing the scheduling task by the thread based on the task object;
the task processing device based on the multithreading environment further comprises:
the judging module is used for judging whether the service main key is read successfully or not;
the primary key lock module is further to: if the service primary key is successfully read, the read service primary key is put into an established lock table;
the task execution module is further configured to: and releasing resources occupied by the scheduling task, starting the next scheduling task in the task list, and executing and reading a service main key preset for the started scheduling task.
6. The multithreading environment-based task processing apparatus of claim 5, further comprising:
and the primary key release module is used for detecting the execution progress of the scheduling task and releasing the service primary key in the lock list when detecting that the scheduling task is completely executed.
7. The multithreading environment-based task processing apparatus of claim 6, further comprising:
the duration acquisition module is used for acquiring the duration of the continuous locking of the service main key in the lock list in a timing mode;
the primary key release module is further configured to: and when detecting that the duration of the continuous locking of the service primary key in the lock table is longer than the preset duration, releasing the service primary key from the lock table.
8. The multithreading environment-based task processing apparatus according to any one of claims 5 to 7, wherein the multithreading environment-based task processing apparatus further comprises:
and the state marking module is used for marking the state of the scheduling task as a processed state when the completion of the execution of the scheduling task is detected.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611233918.6A CN107861799B (en) | 2016-12-28 | 2016-12-28 | Task processing method and device based on multi-thread environment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611233918.6A CN107861799B (en) | 2016-12-28 | 2016-12-28 | Task processing method and device based on multi-thread environment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107861799A CN107861799A (en) | 2018-03-30 |
CN107861799B true CN107861799B (en) | 2020-12-25 |
Family
ID=61698946
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611233918.6A Active CN107861799B (en) | 2016-12-28 | 2016-12-28 | Task processing method and device based on multi-thread environment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107861799B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108804214B (en) * | 2018-05-24 | 2022-04-12 | 创新先进技术有限公司 | Asynchronous task scheduling method and device and electronic equipment |
CN110888723A (en) * | 2019-11-18 | 2020-03-17 | 中国银行股份有限公司 | Timing task processing method and device |
CN111913808B (en) * | 2020-08-19 | 2024-07-30 | 百度时代网络技术(北京)有限公司 | Method, device, equipment and storage medium for task allocation |
CN112148480A (en) * | 2020-09-03 | 2020-12-29 | 深圳壹账通智能科技有限公司 | Task processing method, device and equipment based on multithreading and storage medium |
CN112565366B (en) * | 2020-11-27 | 2022-11-08 | 平安普惠企业管理有限公司 | Distributed file importing method, device, equipment and storage medium |
CN113836161B (en) * | 2021-09-30 | 2023-11-03 | 紫光云技术有限公司 | Method for realizing timed task atomicity by utilizing database lock |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101826003A (en) * | 2010-04-16 | 2010-09-08 | 中兴通讯股份有限公司 | Multithread processing method and device |
CN105095384A (en) * | 2015-07-01 | 2015-11-25 | 北京京东尚科信息技术有限公司 | Method and device for data carrying-over |
CN105700939A (en) * | 2016-04-21 | 2016-06-22 | 北京京东尚科信息技术有限公司 | Method and system for multi-thread synchronization in distributed system |
CN105700937A (en) * | 2016-01-04 | 2016-06-22 | 北京百度网讯科技有限公司 | Multi-thread task processing method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8214433B2 (en) * | 2008-12-15 | 2012-07-03 | International Business Machines Corporation | System and method to provide context for an automated agent to service multiple avatars within a virtual universe |
US20120124342A1 (en) * | 2010-11-12 | 2012-05-17 | International Business Machines Corporation | Concurrent core affinity for weak cooperative multithreading systems |
-
2016
- 2016-12-28 CN CN201611233918.6A patent/CN107861799B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101826003A (en) * | 2010-04-16 | 2010-09-08 | 中兴通讯股份有限公司 | Multithread processing method and device |
CN105095384A (en) * | 2015-07-01 | 2015-11-25 | 北京京东尚科信息技术有限公司 | Method and device for data carrying-over |
CN105700937A (en) * | 2016-01-04 | 2016-06-22 | 北京百度网讯科技有限公司 | Multi-thread task processing method and device |
CN105700939A (en) * | 2016-04-21 | 2016-06-22 | 北京京东尚科信息技术有限公司 | Method and system for multi-thread synchronization in distributed system |
Also Published As
Publication number | Publication date |
---|---|
CN107861799A (en) | 2018-03-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107861799B (en) | Task processing method and device based on multi-thread environment | |
CN108268372B (en) | Mock test processing method and device, storage medium and computer equipment | |
CN111447102B (en) | SDN network device access method and device, computer device and storage medium | |
CN111143163A (en) | Data monitoring method and device, computer equipment and storage medium | |
CN109614164B (en) | Method, device and equipment for realizing configurable plug-in and readable storage medium | |
CN111611057B (en) | Distributed retry method, device, electronic equipment and storage medium | |
CN113407383B (en) | Main and standby system switching method and device, server and main and standby system | |
WO2018099253A1 (en) | Self-starting method and device | |
CN110688206A (en) | Timing task scheduling method and device, computer equipment and storage medium | |
CN107451464B (en) | Prompt message output method and device | |
CN107766131B (en) | Task scheduling method and device | |
CN107729207B (en) | Application program main thread monitoring method and device | |
CN113918407A (en) | Method and device for managing service process and readable storage medium | |
CN106686246B (en) | Short message processing method and terminal | |
CN110231921B (en) | Log printing method, device, equipment and computer readable storage medium | |
CN111190725B (en) | Task processing method, device, storage medium and server | |
CN110162374B (en) | Theme switching method, device, equipment and computer readable storage medium | |
CN108683584B (en) | Message reminding method, device, equipment and storage medium | |
CN109684274B (en) | File archiving method, device and computer readable storage medium | |
CN110837431A (en) | Service control method, service control device, computer equipment and computer-readable storage medium | |
CN112463076B (en) | Data export method, computer equipment and storage medium | |
CN114710556A (en) | Multi-system integrated message pushing method, device, equipment and storage medium | |
CN112463348A (en) | Timed task processing method and device | |
JP2010244116A (en) | Device and method for management of history information, and program | |
CN114254027B (en) | Data processing method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |