Thread allocation method and device, electronic equipment, storage medium and program

The device status information of the thread requesting device is obtained through the thread management and control system and reasonably allocated, solving the problem of unstable equipment and thread operation caused by unreasonable thread allocation in the prior art, and improving the rationality and stability of thread allocation.

CN119690675APending Publication Date: 2025-03-25INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411835616.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The existing thread allocation method does not consider the device status when the server applies for threads, resulting in excessive operating pressure on the server or exceeding the CPU and memory limits, which leads to unstable device operation or unstable thread operation.

Method used

The thread operation permission request and current thread operation information of each thread requesting device are obtained through the thread management and control system, and determine whether the device status of the thread requesting device meets the thread allocation conditions. If it is satisfied, the thread will be allocated according to the thread association attribute information.

Benefits of technology

It improves the rationality of thread allocation, enhances the stability of thread operation and the operation stability of thread request devices, and avoids the problem of unstable threads or devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690675A_ABST
    Figure CN119690675A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a thread allocation method and device, electronic equipment, a storage medium and a program, and can be applied to the technical field of computer application and financial science and technology. The method is applied to a thread management and control system, and comprises the following steps: acquiring a thread operation permission request and current thread operation information sent by each thread request device; wherein the current thread operation information comprises thread association attribute information and thread operation resource limitation information; and allocating a thread requested by the thread request equipment to the thread request equipment according to the thread association attribute information under the condition of determining that the thread request equipment meets a thread allocation condition according to the thread operation resource limitation information and the thread operation permission request. According to the technical scheme provided by the embodiment of the invention, the reasonability of thread distribution can be improved, so that the stability of thread operation and the stability of thread request equipment operation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the fields of computer application and financial technology, and in particular, to a thread allocation method, device, electronic device, storage medium and program. Background Art

[0002] In some business systems (such as banking systems, etc.), servers often use batch threads to complete some operations such as data synchronization and business processing in the background. In order to meet the disaster recovery level requirements, multiple servers are generally running at the same time, but only one thread is allowed to run and process the same operation at the same time, so it is necessary to load balance and control the concurrency of thread resources.

[0003] At present, the main solution for thread allocation is to set up a concurrency control table for thread resources in the database. Before a thread runs, a server needs to access the database to obtain the thread's running permission. When the server obtains the thread running permission, it registers the table, that is, registers the server's own service information in the table, indicating that the server has occupied the thread. Correspondingly, other servers cannot run the running thread because they cannot obtain permission, thereby achieving the purpose of concurrency control.

[0004] In the process of implementing the present invention, the inventors found that the prior art has the following defects: the current thread allocation method does not take into account the device status when the server applies for a thread. If the system device status is not good when the server applies for a thread, even if the server thread running permission application is successful, it will cause the server to run under great pressure, or exceed its own CPU (Central Processing Unit) and memory limits, thereby causing problems such as unstable server device operation or unstable thread operation, thereby causing server failure. Summary of the invention

[0005] The embodiments of the present invention provide a thread allocation method, device, electronic device, storage medium and program, which can improve the rationality of thread allocation, and further improve the stability of thread operation and the stability of thread request device operation.

[0006] According to one aspect of the present invention, a thread allocation method is provided, which is applied to a thread management system, and includes:

[0007] Obtaining thread execution permission requests and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information;

[0008] When it is determined that the thread requesting device meets the thread allocation condition according to the thread execution resource restriction information and the thread execution permission request, the thread requested by the thread requesting device is allocated to the thread requesting device according to the thread association attribute information.

[0009] According to another aspect of the present invention, there is provided a thread allocation device, which is configured in a thread management system and includes:

[0010] A thread information acquisition module, used to acquire the thread execution permission request and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information;

[0011] The thread allocation module is used to allocate the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information when it is determined that the thread requesting device meets the thread allocation condition according to the thread running resource restriction information and the thread running permission request.

[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the thread allocation method described in any embodiment of the present invention.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the thread allocation method described in any embodiment of the present invention when executed.

[0017] According to another aspect of the present invention, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the thread allocation method described in any embodiment of the present invention is implemented.

[0018] The embodiment of the present invention obtains the thread running permission request and the current thread running information sent by each thread requesting device through the thread management and control system, and can determine the thread associated attribute information and the thread running resource restriction information through the current thread running information. Then, when it is determined that the thread requesting device meets the thread allocation condition according to the thread running resource restriction information and the thread running permission request of the thread requesting device, the thread requested by the thread requesting device is allocated to the thread requesting device according to the thread associated attribute information, so as to solve the problem of unstable operation of threads or devices caused by unreasonable thread allocation in the existing thread allocation, and can improve the rationality of thread allocation, thereby improving the stability of thread operation and the stability of operation of the thread requesting device.

[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 is a flowchart of a thread allocation method provided by Embodiment 1 of the present invention;

[0022] Figure 2 is a flowchart of a thread allocation method provided by Embodiment 1 of the present invention;

[0023] Figure 3 It is a schematic diagram of a process of controlling a thread allocation process based on a thread control system provided by Embodiment 2 of the present invention;

[0024] Figure 4 is a schematic diagram of a thread allocation device provided by Embodiment 3 of the present invention;

[0025] Figure 5 A schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0027] It should be noted that the terms "include", "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatus.

[0028] Embodiment 1

[0029] Figure 1 This is a flowchart of a thread allocation method provided in the first embodiment of the present invention. This embodiment is applicable to the case where a thread is allocated to a thread requesting device when the thread requesting device meets the thread allocation conditions. The method can be executed by a thread allocation device, which can be implemented by software and / or hardware, and can generally be integrated in a thread management system. The thread management system can run in an electronic device, which can be a terminal device or a server device. As long as it has a thread management function to execute the thread allocation method, the embodiment of the present invention does not limit the specific device type of the electronic device. Accordingly, Figure 1 As shown, the method includes the following operations:

[0030] S110. Obtain thread execution permission requests and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information.

[0031] Among them, the thread request device may be a device that requests the thread to run from the thread control system. Exemplarily, the thread request device may be a server device that can interact with the thread control system, etc., as long as the device type has the ability to apply for thread permissions from the thread control system. The embodiment of the present invention does not limit the device type of the thread request device. The thread control system may be a system for centralized control of all threads. The thread running permission request may be a request sent by the thread request device to the thread control system to request the running permission of one or more threads. The current thread running information may be the running information related to each thread mastered by the thread control system at the current moment. The thread-related attribute information may be the related attribute information of each thread, for example, it may include but is not limited to various information related to thread attributes such as thread identification such as thread ID (Identification) and thread running state. The embodiment of the present invention does not limit the specific information type and information content of the thread-related attribute information. The thread running resource restriction information may be the resource restriction information configured for each thread, and may include the resource information required for the thread running. Exemplarily, the thread running resource restriction information may include information such as CPU (Central Processing Unit) resources and JVM (Java Virtual Machine) resources required for thread running. As long as they are resources required for thread running, the embodiment of the present invention does not limit the resource types involved in the thread running resource restriction information. The thread allocation condition may be a condition for determining whether a thread requesting device can be allocated its request thread.

[0032] In an embodiment of the present invention, when a thread request device needs to apply for a thread, it can send a thread running permission request to the thread control system. Since the prior art uses a database to uniformly manage thread information, there will be problems such as high database pressure and low efficiency caused by all thread request devices frequently accessing the same database. Therefore, optionally, the thread control system in the embodiment of the present invention can be implemented using a distributed cache system. The thread control system can provide a centralized control function for all thread resources based on the distributed cache system. Since the request concurrency supported by the distributed cache system is higher than that of the database, it can make full use of the high performance, high reliability, elastic scalability and cloud service characteristics of the thread distributed cache, and effectively solve the problems of high database pressure and low efficiency. Exemplarily, the distributed cache system can be a Redis (Remote Dictionary Server, remote dictionary service) system, etc. As long as it can provide a distributed cache function, the embodiment of the present invention does not limit the specific type of the distributed cache system. Accordingly, the thread control system can pre-load the corresponding thread resources from the database and store them in the distributed cache system.

[0033] Accordingly, when the thread control system receives the thread running permission request sent by the thread request device, it can obtain the current thread running information such as the thread association attribute information and thread running resource restriction information of each thread in the current state in real time, so as to grasp the real-time allocation and allocation requirements of each thread in the current state in real time. Exemplarily, the thread control system can determine which threads have been allocated and which threads have not been allocated based on the thread association attribute information. The thread control system can also determine the resource restriction conditions that need to be met for thread allocation based on the thread running resource restriction information.

[0034] S120. When it is determined that the thread requesting device meets a thread allocation condition according to the thread execution resource restriction information and the thread execution permission request, allocate the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information.

[0035] Specifically, after the thread control system obtains the thread running permission request and the current thread running information sent by each thread request device, it can parse and judge each thread running permission request. For each thread running permission request, the thread control system can determine the thread running resource restriction information of the thread requested for allocation, and at the same time, combined with the thread running permission request of the thread request device, judge whether the system resources of the current device of the thread request device requesting the thread meet the requirements of the thread running resource restriction information in the thread. For example, judge whether the current CPU resources and / or JVM resources of the server applying for the thread meet the running requirements of the thread, etc., so as to judge whether the thread request device meets the thread allocation conditions. If it is determined that the thread request device meets the thread allocation conditions, the threads requested by each thread request device can be allocated to the corresponding thread request device according to the thread association attribute information, such as determining the thread identifier requested by the thread request device according to the thread association attribute information, and performing the thread allocation process based on the thread identifier. If it is determined that the thread request device does not meet the thread allocation conditions, the thread requested by the thread request device can be refused to be allocated.

[0036] It can be seen that in the above technical solution, the thread request device that applies for the thread will only be allocated a thread by the thread control system when it meets the thread allocation conditions, such as when the current device resource status meets the thread running resource restriction information corresponding to the applied thread. In this way, the thread request device can meet the thread running conditions during the thread running process, and will not encounter high pressure or exceed the resource running limit when running the thread, thereby ensuring the stable operation of the thread control system and the stable operation of the thread, and avoiding failures of the thread request device during the thread running process.

[0037] The embodiment of the present invention obtains the thread running permission request and the current thread running information sent by each thread requesting device through the thread management and control system, and can determine the thread associated attribute information and the thread running resource restriction information through the current thread running information. Then, when it is determined that the thread requesting device meets the thread allocation condition according to the thread running resource restriction information and the thread running permission request of the thread requesting device, the thread requested by the thread requesting device is allocated to the thread requesting device according to the thread associated attribute information, so as to solve the problem of unstable operation of threads or devices caused by unreasonable thread allocation in the existing thread allocation, and can improve the rationality of thread allocation, thereby improving the stability of thread operation and the stability of operation of the thread requesting device.

[0038] Embodiment 2

[0039] Figure 2 is a flowchart of a thread allocation method provided by the first embodiment of the present invention. This embodiment is specific based on the above embodiment. In this embodiment, multiple specific optional implementation methods are provided for determining that a thread requesting device meets the thread allocation condition, allocating the thread requested by the thread requesting device to the thread requesting device, and completing the subsequent operations of thread allocation. Figure 2 As shown, the method of this embodiment may include:

[0040] S210. Obtain thread execution permission requests and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information.

[0041] S220. When it is determined that the thread requesting device satisfies a thread allocation condition according to the thread execution resource restriction information and the thread execution permission request, allocate the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information.

[0042] In an optional embodiment of the present invention, the thread running permission request may include a thread identifier and current device system resources; determining that the thread requesting device satisfies the thread allocation condition based on the thread running resource restriction information and the thread running permission request of the thread requesting device may include: matching the thread identifier in the thread running permission request of the thread requesting device with the thread associated attribute information of the current thread running information to determine the thread requested by the thread requesting device; determining the thread running resource restriction information of the thread from the current thread running information; comparing the current device system resources in the thread running permission request of the thread requesting device with the thread running resource restriction information of the thread; and determining that the thread requesting device satisfies the thread allocation condition when it is determined that the current device system resources satisfy the thread running resource restriction information of the thread and the current thread running state of the thread is a non-running state.

[0043] The thread identifier can be used to uniquely identify the thread, for example, it can be a thread ID, etc. The embodiment of the present invention does not limit the specific type of the thread identifier. The current device system resource can be the device system resource of the thread requesting device in the state of initiating the thread running permission request, which can be used to determine whether the thread requesting device currently meets the thread allocation condition.

[0044] Optionally, the thread requesting device can generate a thread running permission request based on the thread identifier and the current device system resources to actively report the current device system resources to the thread control system. Correspondingly, the thread control system can parse the thread identifier in the thread running permission request, and match the thread associated attribute information of the current thread running information according to the parsing result, so as to determine the thread requested by the thread requesting device for allocation. Further, the thread control system determines the thread running resource restriction information of the thread from the current thread running information, and compares the current device system resources of the thread requesting device with the thread running resource restriction information of the thread requesting thread. If it is determined that the current device system resources meet the thread running resource restriction information of the requested thread, and the current thread running state of the requested thread is not running, it can be determined that the thread requesting device meets the thread allocation condition. If it is determined that the current device system resources do not meet the thread running resource restriction information of the requested thread, and / or it is determined that the current thread running state of the requested thread is running (the running state indicates that the thread has been allocated and running), it can be determined that the thread requesting device does not meet the thread allocation condition.

[0045] The above technical solution can reduce the computing pressure on the thread request device side by having the thread management system execute the computing processes associated with all threads, and improve the centralized control function of the thread management system on the threads.

[0046] In an optional embodiment of the present invention, the thread running permission request may include a thread identifier; determining that the thread requesting device meets the thread allocation condition based on the thread running resource restriction information and the thread running permission request of the thread requesting device may include: in response to the thread running permission request, determining the thread running information of the thread from the current thread running information based on the thread identifier; sending the thread running information to the thread requesting device; wherein the thread requesting device may also be used to: obtain the current device system resources of the local device in real time; compare the current device system resources with the thread running resource restriction information of the thread; when it is determined that the current device system resources meet the thread running resource restriction information of the thread and the current thread running state of the thread is not running, determine that the thread requesting device meets the thread allocation condition; and feedback the thread matching result information of the thread to the thread management and control system.

[0047] Optionally, the thread request device can also generate a thread running permission request based only on the thread identifier. Accordingly, the thread control system can respond to the thread running permission request, determine the thread running information of its request thread from the current thread running information according to the thread identifier carried in the request, and send the thread running information of its request thread to the corresponding thread request device. After the thread request device receives the thread running information of its request thread, it can obtain the current device system resources of the local device in real time, and compare the obtained current device system resources with the thread running resource restriction information of its request thread. If it is determined that the current device system resources meet the thread running resource restriction information of its request thread, and the current thread running state of its request thread is not running, it can be determined that the thread request device meets the thread allocation condition. If it is determined that the current device system resources do not meet the thread running resource restriction information of its request thread, and / or it is determined that the current thread running state of its request thread is running, it can be determined that the thread request device does not meet the thread allocation condition. Regardless of whether the thread requesting device meets the thread allocation condition, the thread requesting device can feed back the thread matching result information of its requested thread to the thread control system, that is, the thread matching result information that the thread requesting device meets the thread allocation condition or the thread requesting device does not meet the thread allocation condition. Accordingly, the thread control system can determine whether the thread requesting device meets the thread allocation condition based on the thread matching result information fed back by the thread requesting device.

[0048] In the above technical solution, the thread requesting device determines whether it meets the thread allocation condition according to the current device system resources obtained in real time, which can ensure the real-time and accuracy of the thread allocation condition judgment, thereby improving the accuracy of thread allocation.

[0049] In an optional embodiment of the present invention, there are multiple thread requesting devices requesting the thread; and allocating the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information may include: obtaining the estimated thread occupancy time of each thread requesting device requesting the thread; and allocating the thread to the thread requesting device with the smallest estimated thread occupancy time.

[0050] The estimated thread occupancy time may be the total estimated running time of the thread in the thread requesting device.

[0051] It is understandable that the same thread may run for different lengths of time in different thread request devices. At the same time, there may be multiple different thread request devices requesting to allocate the same thread resource at the same time. If there are multiple different thread request devices requesting to allocate the same thread resource at the same time, and there are multiple thread request devices that meet the thread running resource restriction information of the thread, that is, there are multiple thread request devices that meet the thread allocation condition of the thread, then a certain strategy can be adopted to select one of the thread request devices from the multiple thread request devices that meet the thread allocation condition to allocate the thread resource.

[0052] Optionally, the running time of the thread resource by each thread requesting device can be used as the allocation basis to obtain information on the estimated thread occupancy time requested by each thread requesting device for the thread. Optionally, the estimated thread occupancy time can be calculated by each thread requesting device and reported to the thread management and control system. Alternatively, the thread management and control system can also calculate the estimated thread occupancy time of each thread requesting device based on the thread running permission request sent by each thread requesting device. The embodiment of the present invention does not limit the calculation method of the estimated thread occupancy time. Accordingly, the thread management and control system can allocate the thread to the thread requesting device with the smallest estimated thread occupancy time for operation. The advantage of such a setting is that the thread resources can serve more thread requesting devices in a short period of time, which can improve the utilization rate of the thread resources.

[0053] In an optional embodiment of the present invention, the number of the thread requesting devices requesting the thread is multiple; the allocating the thread requested by the thread requesting device to the thread requesting device according to the thread associated attribute information may also include: comparing the current device system resources of each thread requesting device, and allocating the thread to the thread requesting device with the most sufficient current device system resources. The advantage of such a setting is that it can avoid to the greatest extent the problem that the system resources are unable to meet the thread running requirements and the thread running is unstable due to the thread requesting device processing other tasks during the thread running process, thereby ensuring the stability of the thread running to the greatest extent.

[0054] S230: Synchronously update the thread-related attribute information in the current thread running information of the thread according to the information of the thread request device, and configure the current thread running cycle duration for the thread.

[0055] The thread-related attribute information may include a thread identifier, a thread running state, and a thread request device identifier.

[0056] Among them, the thread running state can represent the specific running state of the thread. It is understandable that if the thread running state of the thread is not running, it means that the thread has not been assigned. If the thread running state of the thread is running, it means that the thread has been assigned, and other thread request devices temporarily do not have the running permission for the thread. The thread request device identifier can be the device identifier assigned to the thread request device by the thread. The current thread running cycle duration can be the running cycle duration currently configured for the assigned thread.

[0057] It is understandable that after a thread is assigned to a corresponding thread request device, the thread control system needs to update the thread running information of the assigned thread. Specifically, the thread control system can synchronously update the thread-related attribute information of the thread according to the information of the thread request device corresponding to the assigned thread. For example, the thread running state of the thread can be first updated from a non-running state to a running state, and the thread request device identifier of the thread request device corresponding to the thread can be recorded, such as recording the device ID of the running thread. At the same time, for the assigned thread, the current thread running cycle duration can also be configured to specify the maximum running time of the assigned thread. Optionally, the current thread running cycle durations configured for different threads can be the same or different, and the embodiment of the present invention does not limit this. The current thread running cycle durations configured for the same thread at different times can be the same or different, and the embodiment of the present invention does not limit this either.

[0058] The above technical solution can prevent the allocated thread from being mistakenly allocated to other thread request devices by timely updating the attribute information of the allocated thread. At the same time, by configuring the current thread running cycle length for the allocated thread, it can prevent the thread from being occupied by the same thread request device for a long time, and prevent other thread request devices from being unable to obtain the running permission of the thread due to thread abnormality.

[0059] S240: Obtain thread monitoring information of the thread in real time.

[0060] The thread monitoring information may be information obtained by real-time monitoring of the allocated threads.

[0061] Optionally, the allocated thread can periodically send heartbeat messages to the thread control system during operation to periodically report the survival status to the thread control system. The thread control system can use the heartbeat messages of the allocated thread and the accumulated running time counted in real time as thread monitoring information of the thread.

[0062] S250: When it is determined according to the thread monitoring information of the thread that the accumulated running time of the thread exceeds the running cycle time of the current thread, delete the thread request device identification information in the current thread running information of the thread.

[0063] During the operation of the allocated threads, the thread management system can count the cumulative running time of each allocated thread from the allocation time to the current time in real time. It is understandable that if the cumulative running time of an allocated thread exceeds the current thread running cycle time of its corresponding configuration, it indicates that the thread request device running the thread is likely to be abnormal and unable to effectively update the thread information. In this case, the thread management system can promptly delete the thread request device identification information in the current thread running information of the thread. Optionally, the thread management system can also update the thread running state of the thread to a non-running state to avoid the thread being unable to be allocated to other thread request devices, resulting in a waste of thread resources.

[0064] S260: When it is determined according to the thread monitoring information of the thread that the heartbeat message of the thread is abnormal, generate abnormal alarm information for the thread.

[0065] During the running of the thread, the thread control system can also collect the heartbeat messages of each assigned thread in real time. If there is no abnormality in the heartbeat message, it indicates that the thread is running normally. If the heartbeat message is not received for a long time, it indicates that the thread is abnormal, and an abnormal alarm message can be generated to trigger an alarm to remind the operation and maintenance personnel to intervene.

[0066] Optionally, monitoring the thread running status through heartbeat messages can also be implemented by an independent monitoring system. That is, the thread control system only controls the thread running information, and the additional monitoring system receives the heartbeat messages of each assigned thread in real time and determines whether the thread is abnormal. The embodiment of the present invention does not limit the specific implementation method of monitoring the thread running status through heartbeat messages.

[0067] The above technical solution monitors the allocated threads in real time by acquiring the thread monitoring information of the allocated threads in real time, so as to grasp the dynamics of the allocated threads in real time, and promptly process abnormal device information or trigger alarm intervention when problems occur in the allocated threads, thereby improving the utilization rate of thread resources and ensuring the stability and reliability of thread operation.

[0068] Figure 3FIG. 1 is a flow chart of controlling the thread allocation process based on the thread control system provided in the second embodiment of the present invention. In a specific example, Figure 3 As shown in the figure, the overall process of thread allocation management is illustrated by taking the thread request server as the thread request device:

[0069] Step 1: Initialize thread running information in the thread control system, including but not limited to: thread ID, thread running status, thread running server ID, and resource information required for thread running.

[0070] Step 2: When a thread in the thread request server is started, the thread running information of this type of thread is obtained from the thread management system according to the thread ID. If the running status of the request thread is "1-Running", it indicates that the thread is occupied by other devices and the process ends; if the running status of the request thread is "0-Not Running", a comprehensive judgment is made as to whether the current server resources (such as CPU and JVM resources, etc.) can meet the resources required for the running of the request thread. If not, the process ends and other server threads with resources can obtain the running permission of the thread; if satisfied, the thread running status of the thread in the thread management system is updated to "1-Running", and the thread running server ID of the thread is updated to the ID of the current thread request server, and the data life cycle of the thread is set to the maximum running length of the thread.

[0071] Step 3: When the thread is running, it sends heartbeat messages to the thread monitoring system regularly.

[0072] Step 4: If the thread management system determines that the thread running information data of the thread exceeds the data life cycle (i.e., the maximum running time of the thread), indicating that the server running the thread may be abnormal, it will automatically clean up the information of the thread running server ID corresponding to the thread to prevent other threads from requesting the server thread to obtain the running permission of the thread.

[0073] Step 5: If the monitoring system determines that a thread has not sent a heartbeat message for a long time, it determines that the thread is abnormal and triggers an alarm, reminding the operation and maintenance personnel to intervene.

[0074] The above technical solution provides a thread allocation method that fully utilizes the high performance, high reliability, elastic scalability and cloud service characteristics of thread distributed cache, reasonably schedules threads, evenly uses thread resources, improves the stability of thread operation, and ensures the normal and stable development of business.

[0075] In the technical solution of the present disclosure, the collected information involved is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0076] It should be noted that any arrangement and combination of the technical features in the above embodiments also falls within the protection scope of the present invention.

[0077] Embodiment 3

[0078] Figure 4 is a schematic diagram of a thread allocation device provided by Embodiment 3 of the present invention, such as Figure 4 As shown, the device includes: a thread information acquisition module 310 and a thread allocation module 320, wherein:

[0079] The thread information acquisition module 310 is used to acquire the thread execution permission request and the current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information;

[0080] The thread allocation module 320 is used to allocate the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information when it is determined that the thread requesting device meets the thread allocation condition according to the thread running resource restriction information and the thread running permission request.

[0081] The embodiment of the present invention obtains the thread running permission request and the current thread running information sent by each thread requesting device through the thread management and control system, and can determine the thread associated attribute information and the thread running resource restriction information through the current thread running information. Then, when it is determined that the thread requesting device meets the thread allocation condition according to the thread running resource restriction information and the thread running permission request of the thread requesting device, the thread requested by the thread requesting device is allocated to the thread requesting device according to the thread associated attribute information, so as to solve the problem of unstable operation of threads or devices caused by unreasonable thread allocation in the existing thread allocation, and can improve the rationality of thread allocation, thereby improving the stability of thread operation and the stability of operation of the thread requesting device.

[0082] Optionally, the thread running permission request includes a thread identifier and current device system resources; the thread allocation module 320 is also used to: match the thread identifier in the thread running permission request of the thread requesting device with the thread associated attribute information of the current thread running information to determine the thread requested by the thread requesting device; determine the thread running resource restriction information of the thread from the current thread running information; compare the current device system resources in the thread running permission request of the thread requesting device with the thread running resource restriction information of the thread; and when it is determined that the current device system resources meet the thread running resource restriction information of the thread and the current thread running state of the thread is not running, determine that the thread requesting device meets the thread allocation condition.

[0083] Optionally, the thread running permission request includes a thread identifier; the thread allocation module 320 is also used to: respond to the thread running permission request, determine the thread running information of the thread from the current thread running information according to the thread identifier; send the thread running information to the thread requesting device; wherein the thread requesting device is used to: obtain the current device system resources of the local device in real time; compare the current device system resources with the thread running resource restriction information of the thread; when it is determined that the current device system resources meet the thread running resource restriction information of the thread and the current thread running state of the thread is a non-running state, determine that the thread requesting device meets the thread allocation conditions; and feedback the thread matching result information of the thread to the thread management and control system.

[0084] Optionally, there are multiple thread requesting devices requesting the thread; the thread allocation module 320 is also used to: obtain the estimated thread occupancy time of each thread requesting device requesting the thread; and allocate the thread to the thread requesting device with the smallest estimated thread occupancy time.

[0085] Optionally, the above-mentioned device also includes a thread information updating module, which is used to: synchronously update the thread-related attribute information in the current thread running information of the thread according to the information of the thread request device; wherein the thread-related attribute information includes the thread identifier, the thread running state and the thread request device identifier; and configure the current thread running cycle duration for the thread.

[0086] Optionally, the above-mentioned device also includes a thread monitoring module, which is used to: obtain thread monitoring information of the thread in real time; when it is determined according to the thread monitoring information of the thread that the cumulative running time of the thread exceeds the running cycle time of the current thread, delete the thread request device identification information in the current thread running information of the thread; when it is determined according to the thread monitoring information of the thread that the heartbeat message of the thread is abnormal, generate abnormal alarm information for the thread.

[0087] The thread allocation device can execute the thread allocation method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, please refer to the thread allocation method provided by any embodiment of the present invention.

[0088] Since the thread allocation device described above is a device that can execute the thread allocation method in the embodiment of the present invention, based on the thread allocation method described in the embodiment of the present invention, those skilled in the art can understand the specific implementation of the thread allocation device of the present embodiment and its various variations, so how the thread allocation device implements the thread allocation method in the embodiment of the present invention is not described in detail here. As long as those skilled in the art implement the device used in the thread allocation method in the embodiment of the present invention, it belongs to the scope of protection of this application.

[0089] Embodiment 4

[0090] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0091] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0092] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0093] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a thread allocation method.

[0094] Optionally, the thread allocation method is applied to the thread management system, including:

[0095] Obtaining thread execution permission requests and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information;

[0096] When it is determined that the thread requesting device meets the thread allocation condition according to the thread execution resource restriction information and the thread execution permission request, the thread requested by the thread requesting device is allocated to the thread requesting device according to the thread association attribute information.

[0097] In some embodiments, the thread allocation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the thread allocation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the thread allocation method in any other appropriate manner (e.g., by means of firmware).

[0098] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0099] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0100] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer 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 foregoing.

[0101] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0102] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0103] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0104] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0105] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A thread allocation method, characterized in that: Applied to thread management system, including: Obtaining thread execution permission requests and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information; When it is determined that the thread requesting device meets the thread allocation condition according to the thread execution resource restriction information and the thread execution permission request, the thread requested by the thread requesting device is allocated to the thread requesting device according to the thread association attribute information.

2. The method according to claim 1, characterized in that The thread execution permission request includes a thread identifier and current device system resources; and determining that the thread requesting device meets the thread allocation condition according to the thread execution resource restriction information and the thread execution permission request of the thread requesting device includes: According to the thread identifier in the thread execution permission request of the thread requesting device and the thread associated attribute information of the current thread execution information, the thread requested by the thread requesting device is determined; Determine thread running resource restriction information of the thread from the current thread running information; Comparing the current device system resources in the thread execution permission request of the thread requesting device with the thread execution resource restriction information of the thread; When it is determined that the current device system resources satisfy the thread running resource restriction information of the thread and the current thread running state of the thread is a non-running state, it is determined that the thread requesting device satisfies the thread allocation condition.

3. The method according to claim 1, characterized in that The thread execution permission request includes a thread identifier; and determining that the thread requesting device meets the thread allocation condition according to the thread execution resource restriction information and the thread execution permission request of the thread requesting device includes: In response to the thread execution permission request, determining thread execution information of the thread from the current thread execution information according to the thread identifier; Sending the thread running information to the thread requesting device; Wherein, the thread request device is used for: Get the current device system resources of the local device in real time; Comparing the current device system resources with thread running resource restriction information of the thread; In the case where it is determined that the current device system resources satisfy the thread running resource restriction information of the thread, and the current thread running state of the thread is a non-running state, determining that the thread requesting device satisfies the thread allocation condition; Feedback the thread matching result information of the thread to the thread management system.

4. The method according to claim 1, characterized in that The number of the thread requesting devices requesting the thread is multiple; and the allocating the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information includes: Obtaining the estimated thread occupancy time requested by each thread requesting device for the thread; The thread is allocated to the thread requesting device with the smallest estimated thread occupancy time.

5. The method according to claim 1, characterized in that After allocating the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information, the method further includes: Synchronously updating the thread-related attribute information in the current thread running information of the thread according to the information of the thread requesting device; wherein the thread-related attribute information includes a thread identifier, a thread running state and a thread requesting device identifier; The current thread running cycle duration is configured for the thread.

6. The method according to claim 5, characterized in that The method further comprises: Obtaining thread monitoring information of the thread in real time; When it is determined according to the thread monitoring information of the thread that the accumulated running time of the thread exceeds the running cycle time of the current thread, deleting the thread request device identification information in the current thread running information of the thread; When it is determined according to the thread monitoring information of the thread that the heartbeat message of the thread is abnormal, abnormal alarm information is generated for the thread.

7. A thread allocation device, characterized in that: Configured in the thread control system, including: A thread information acquisition module, used to acquire the thread execution permission request and current thread execution information sent by each thread request device; wherein the current thread execution information includes thread association attribute information and thread execution resource restriction information; The thread allocation module is used to allocate the thread requested by the thread requesting device to the thread requesting device according to the thread association attribute information when it is determined that the thread requesting device meets the thread allocation condition according to the thread running resource restriction information and the thread running permission request.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the thread allocation method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the thread allocation method described in any one of claims 1 to 6 when executed.

10. A computer program product comprising a computer program / instructions, wherein: When the computer program / instructions are executed by a processor, the thread allocation method described in any one of claims 1 to 6 is implemented.