Timer processing method and device, electronic equipment and computer program product

By introducing inter-thread communication and timer control mechanisms into timer processing, the timing disordered exceptions in the timer processing solution are solved, ensuring that message calls are completed, and product performance and user experience are improved.

CN120371471APending Publication Date: 2025-07-25LAUNCH TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510437408.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-08
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

Existing timer processing solutions are prone to timing disorders and abnormalities, affecting product performance and user experience.

Method used

By sending a message to the second thread after the first thread receives the timing task, the first thread waits, the second thread starts the timer and controls the first thread to continue running, and executes the code block associated with the timer at the end of the timing to ensure that the message call is completed.

Benefits of technology

Reduces the risk of timing error exceptions between multithreading and timers, and improves product performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371471A_ABST
    Figure CN120371471A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of computers, and provides a timer processing method and device, electronic equipment and a computer program product. The processing method of the timer comprises the following steps: in response to a timing task received by a first thread, sending a message to a second thread, and controlling the first thread to wait; in response to the message received by the second thread, controlling a timer to start through the second thread, and controlling the first thread to continue running; and when the timing of the timer is finished, executing the code block associated with the timer, and finishing the timing task when the code block is executed. According to the embodiment of the invention, the message calling completion can be ensured, and the risk of time sequence error abnormity between multiple threads and the timer is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and particularly relates to a method and device for processing a timer, an electronic device, and a computer program product. Background Art

[0002] In the process of diagnostic development, the implementation of time-related communication parameters is often involved, especially the implementation of standard protocol communication libraries such as J2534 and D-PDU. Inevitably, it is necessary to handle the logical relationship between threads and timers well. In the current timer processing solutions, occasional exceptions are inevitable, such as timing disorder exceptions, which seriously affect the product performance and user experience. Summary of the Invention

[0003] Embodiments of this application provide a method and device for processing a timer, an electronic device, and a computer program product, which can ensure the completion of message calls and reduce the risk of timing error exceptions between multi-threads and the timer.

[0004] A first aspect of embodiments of this application provides a method for processing a timer, including: in response to a first thread receiving a timing task, sending a message to a second thread and controlling the first thread to wait; in response to the second thread receiving the message, controlling the timer to start through the second thread and controlling the first thread to continue running; when the timing of the timer ends, executing a code block associated with the timer, and completing the timing task when the code block is executed.

[0005] In some embodiments of the first aspect, the controlling the first thread to wait includes: creating an event object associated with the timer; setting the event state of the event object to a first state, where the first state is used to indicate that the first thread waits.

[0006] In some embodiments of the first aspect, the controlling the first thread to continue running includes: updating the event state of the event object to a second state, where the second state is used to indicate that the first thread continues running.

[0007] In some embodiments of the first aspect, during the execution of the code block associated with the timer, it further includes: if the object called during the execution of the code block includes a mutex object, obtaining the state of the mutex object; if the state of the mutex object is an idle state, entering the critical section where the mutex object is located to execute code to call the mutex object.

[0008] In some embodiments of the first aspect, the sending a message to the second thread includes: sending a message to the second thread according to the thread handle of the second thread.

[0009] In some embodiments of the first aspect, after executing the code associated with the timer, it further includes: closing the timer through the second thread.

[0010] In some embodiments of the first aspect, the timing task is used to initiate a vehicle diagnostic instruction.

[0011] A processing device for a timer provided in the second aspect of the embodiments of the present application includes: a task response unit, configured to, in response to a first thread receiving a timing task, send a message to a second thread and control the first thread to wait; a message processing unit, configured to, in response to the second thread receiving the message, control the timer to start through the second thread and control the first thread to continue running; a timer control unit, configured to, when the timing of the timer ends, execute a code block associated with the timer, and when the code block is executed, complete the timing task.

[0012] The third aspect of the embodiments of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned timer processing method are implemented.

[0013] The fourth aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned timer processing method are implemented.

[0014] The fifth aspect of the embodiments of the present application provides a computer program product, and when the computer program is run, the above-mentioned timer processing method is executed.

[0015] In the embodiments of the present application, in response to the first thread receiving a timing task, by sending a message to the second thread and controlling the first thread to wait, and then, in response to the second thread receiving the message, controlling the timer to start through the second thread and controlling the first thread to continue running, when the timing of the timer ends, executing a code block associated with the timer, and when the code block is executed, completing the timing task, which can ensure the completion of message calls and reduce the risk of timing error exceptions between multiple threads and the timer. Description of the Drawings

[0016] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0017] Figure 1 It is a schematic diagram of the implementation process of a processing method for a timer provided by an embodiment of the present application;

[0018] Figure 2 It is a schematic structural diagram of a processing device for a timer provided by an embodiment of the present application;

[0019] Figure 3 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0020] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.

[0021] During the diagnostic development process, the implementation of time-related communication parameters is often involved, especially the implementation of standard protocol communication libraries such as J2534 and D-PDU. It is inevitable to handle the logical relationship between threads and timers well. In the current timer processing solution, occasional exceptions are inevitable, such as timing disorder exceptions, which seriously affect the product performance and user experience.

[0022] In view of this, the present application proposes a processing method for a timer, which can ensure the completion of message calls and reduce the risk of timing error exceptions between multi-threads and timers.

[0023] In order to illustrate the technical solutions of the present application, the following will be described through specific embodiments.

[0024] Figure 1 It shows a schematic diagram of the implementation process of a processing method for a timer provided by an embodiment of the present application. This method can be applied to an electronic device. In the embodiment of the present application, the above-mentioned electronic device can be an intelligent device such as a computer, a tablet computer, a mobile phone, a diagnostic device, a vehicle-mounted device, etc., and the present application does not make any restrictions in this regard.

[0025] Specifically, the processing method for the above-mentioned timer may include the following steps S101 to S104.

[0026] Step S101, in response to the first thread receiving a timing task, send a message to the second thread and control the first thread to wait.

[0027] In an embodiment of the present application, the first thread is a thread for data processing and can receive a timing task to execute the received timing task. Among them, the timing task can be initiated by the user or generated by the electronic device according to a preset task plan, and the present application does not limit this.

[0028] In response to the first thread receiving a timing task, the first thread can execute a code block to send a message to the second thread. This message can be used to instruct the second thread to perform timer processing.

[0029] When sending a message to the second thread, the first thread can be controlled to wait. Controlling the first thread to wait can mean controlling the first thread to stop executing the code and recording the code line position at the stop, so as to avoid data read and write during code execution causing a timer processing data conflict and then a timing error exception.

[0030] Step S102, in response to the second thread receiving the message, control the timer to start through the second thread, and control the first thread to continue running.

[0031] In an embodiment of the present application, the second thread is a thread for processing messages such as timers. After receiving the message sent by the first thread, the second thread can control the timer to start to perform timing control according to the requirements of the timing task. After the timer starts, the first thread can be controlled to continue running, and the "continue running" can mean controlling the first thread to continue executing the code starting from the code line position at the stop.

[0032] Step S103, when the timing of the timer ends, execute the code block associated with the timer, and the timing task is completed when the code block is executed.

[0033] After the timer starts, it can start timing and execute the code block associated with the timer after the timing ends. The timing task can be completed according to the task requirements of the timing task when the code block is executed.

[0034] In an embodiment of the present application, in response to the first thread receiving a timing task, by sending a message to the second thread and controlling the first thread to wait, then, in response to the second thread receiving the message, controlling the timer to start through the second thread and controlling the first thread to continue running, when the timing of the timer ends, execute the code block associated with the timer, and the timing task is completed when the code block is executed, which can ensure the completion of message calls and reduce the risk of timing error exceptions between multiple threads and timers.

[0035] Specifically, in some embodiments of the present application, the above-mentioned sending a message to the second thread may include: sending a message to the second thread according to the thread handle of the second thread.

[0036] Among them, a thread handle can be used to uniquely identify a thread, so as to distinguish and operate different threads. When creating the second thread, the electronic device can record the thread handle of the second thread. In response to the first thread receiving a timing task, the first thread can send a message to the second thread according to the thread handle of the second thread, ensuring that the second thread can accurately receive the message.

[0037] Specifically, in some embodiments of the present application, the first thread can send a message to the message queue of the second thread through functions such as PostThreadMessag.

[0038] In some embodiments of the present application, controlling the first thread to wait may include: creating an event object, associating the event object with a timer, setting the event state of the event object to a first state, and the first state is used to indicate that the first thread waits.

[0039] Specifically, an event object is a kernel object used for synchronization between threads. Through the CreateEvent function, an event object can be created, and the created object can be waited for by multiple threads to achieve synchronization between threads. The event object can achieve synchronous communication through its event state. A thread can wait for an event to become signaled, while another thread can notify the waiting thread by setting the event state. Specifically, between threads, the SetEvent function can be used to set the event state to signaled. And the WaitForSingleObject function can be used to wait. If the event is in a nonsignaled state, the wait function will block the calling thread until the event becomes signaled or times out.

[0040] Correspondingly, different timers can be associated with different event objects. By setting the event state of the event object associated with the timer to the first state (i.e., the nonsignaled state), the WaitForSingleObject function called by the first thread can block the first thread until the event state becomes signaled or times out.

[0041] After receiving the message, the second thread can control the timer to start and control the first thread to continue running.

[0042] Specifically, the thread processing function of the second thread is OnMessageThread. OnMessageThread is a function used to process messages in a multithreaded environment and can distribute the messages in the message queue to the second thread for processing. Among them, the second thread reads and processes the messages through functions such as the GetMessage function. The GetMessage function is a standard system function in Windows programming for obtaining messages from the message queue.

[0043] After receiving the message, the second thread can set a timer through the SetTimer function. By starting the timer, a time interval can be specified to periodically trigger an event or execute a specified process.

[0044] In some embodiments of the present application, controlling the first thread to continue running may include: updating the event state of the event object to a second state, where the second state is used to indicate that the first thread continues to run.

[0045] Specifically, while starting the timer, the second thread can set the aforementioned event object to the second state (signaled state) through the SetEvent function, so that the WaitForSingleObject function called by the first thread ends the blocking of the first thread and controls the first thread to continue running.

[0046] As the timer runs, when the timing of the timer ends, the code block associated with the timer can be executed, and the timing task is completed when the code block is executed.

[0047] Specifically, when the timer is triggered, Windows sends a WM_TIMER message to the window associated with the timer, and this WM_TIMER message can be processed in the program to execute the code block related to the timing task corresponding to the timer.

[0048] In some embodiments of the present application, the above timing task can be used to initiate a vehicle diagnostic instruction. Then, when the code block associated with the timer is executed, the electronic device can initiate a vehicle diagnostic instruction to implement vehicle diagnosis.

[0049] In some embodiments of the present application, during the process of executing the code block associated with the timer, it may further include: if the object called when the code block is executed includes a mutex object, obtain the state of the mutex object, and if the state of the mutex object is the idle state, enter the critical section where the mutex object is located to execute the code to call the mutex object.

[0050] Among them, a mutex is a shared resource used to prevent multiple threads from accessing simultaneously, which can refer to a global variable. Specifically, a mutex is used to protect a critical section to ensure that only one thread can enter the critical section to execute code at any time. If the object called when the code block associated with the timer is executed includes a mutex, the status of the mutex needs to be obtained. If the status of the mutex is the idle state, the second thread can enter the protected critical section where the mutex is located to execute the code to call the mutex and complete the execution of the code block. Correspondingly, if the status of the mutex is the occupied state, the second thread can wait for the status of the mutex to switch to the idle state and then enter the protected critical section where the mutex is located to execute the code to call the mutex. In this way, data competition and inconsistency caused by multiple threads accessing shared resources simultaneously can be prevented.

[0051] In some embodiments of the present application, after executing the code associated with the timer, it may further include: closing the timer through a second thread. Specifically, the timer can be closed by calling the KillTimer function, and the KillTimer function is used to destroy the specified timer.

[0052] For ease of understanding, the processing method of the timer in the present application will be described below through a specific process.

[0053] Step S1, create a mutex as needed.

[0054] Step S2, create an event object as needed.

[0055] Step S3, create a thread for processing messages such as timers, that is, the aforementioned second thread.

[0056] Step S4, create other threads for data processing, that is, the first thread.

[0057] Step S5, in response to the first thread receiving a timing task, send a message to the second thread and control the first thread to wait. Specifically, when the first thread receives a timing task, it calls the PostThreadMessag function to send a message to the second thread and controls the first thread to wait by setting the event status.

[0058] Step S6, the second thread receives the message, controls the timer to start, and controls the first thread to continue running. Specifically, the second thread receives the message through the OnMessageThread function, starts the timer through the SetTimer function to start timing, and controls the first thread to continue to perform other operations by setting the event status.

[0059] Step S7, when the timing of the timer ends, execute the code block associated with the timer to complete the timing task. Specifically, after the timing ends, the WM_TIMER function is triggered to execute the logic code related to the timer, such as initiating a vehicle diagnostic instruction, etc.

[0060] Step S8, turn off the timer.

[0061] Thus, through the event object, orderly management can be carried out between the first thread and the second thread to ensure the stable operation of the timer. At the same time, based on the mutex object, data access conflicts between different threads can be avoided, which is helpful for multi-thread and timer processing. Especially in vehicle diagnostic tasks, it can effectively implement the time-related diagnostic communication parameter function and avoid data access conflicts, timing error exceptions, etc.

[0062] In practical applications, the second thread can receive one or more messages sent by the first thread, process each message separately, and set a timer corresponding to each message. Through multiple timers, multi-task processing can be achieved, thereby improving the processing efficiency.

[0063] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be carried out in other sequences.

[0064] As Figure 2 shown is a schematic structural diagram of a timer processing device 200 provided by an embodiment of the present application, and the timer processing device 200 is configured on an electronic device.

[0065] Specifically, the timer processing device 200 may include:

[0066] A task response unit 201, configured to respond to the first thread receiving a timing task, send a message to the second thread, and control the first thread to wait;

[0067] A message processing unit 202, configured to respond to the second thread receiving the message, control the timer to start through the second thread, and control the first thread to continue running;

[0068] A timer control unit 203, configured to execute the code block associated with the timer when the timing of the timer ends, and the code block completes the timing task when executed.

[0069] In some embodiments of the present application, the task response unit 201 may be specifically configured to: create an event object, where the event object is associated with the timer; set the event status of the event object to a first status, and the first status is used to indicate that the first thread is waiting.

[0070] In some embodiments of the present application, the message processing unit 202 may be specifically configured to: update the event status of the event object to a second status, and the second status is used to indicate that the first thread continues to run.

[0071] In some embodiments of the present application, the timer control unit 203 may be specifically configured to: if the object called during the execution of the code block includes a mutex object, obtain the status of the mutex object; if the status of the mutex object is an idle state, enter the critical section where the mutex object is located to execute the code to call the mutex object.

[0072] In some embodiments of the present application, the task response unit 201 may be specifically configured to: send a message to the second thread according to the thread handle of the second thread.

[0073] In some embodiments of the present application, the timer control unit 203 may also be specifically configured to: close the timer through the second thread.

[0074] In some embodiments of the present application, the timing task is used to initiate a vehicle diagnosis instruction.

[0075] It should be noted that, for the convenience and brevity of description, the specific working process of the above-mentioned processing device 200 of the timer can refer to Figure 1 the corresponding process of the method, which will not be elaborated here.

[0076] As Figure 3 shown, it is a schematic diagram of an electronic device provided by an embodiment of the present application. Specifically, the electronic device 3 may include: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a processing program of the timer. When the processor 30 executes the computer program 32, the steps in the above-mentioned various embodiments of the timer processing method are implemented, such as Figure 1 the steps S101 to S103 shown. Or, when the processor 30 executes the computer program 32, the functions of each module / unit in the above-mentioned various device embodiments are implemented, such as Figure 2 the functions of the task response unit 201, the message processing unit 202, and the timer control unit 203 shown.

[0077] The computer program can be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 30 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the electronic device.

[0078] For example, the computer program can be divided into: a task response unit, a message processing unit, and a timer control unit. The specific functions of each unit are as follows: The task response unit is configured to, in response to the first thread receiving a timing task, send a message to the second thread and control the first thread to wait; the message processing unit is configured to, in response to the second thread receiving the message, control the timer to start through the second thread and control the first thread to continue running; the timer control unit is configured to, when the timing of the timer ends, execute a code block associated with the timer, and when the code block is executed, the timing task is completed.

[0079] The electronic device may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art can understand that Figure 3 merely examples of the electronic device do not constitute a limitation on the electronic device, and it may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, the electronic device may further include input / output devices, network access devices, a bus, etc.

[0080] The so-called processor 30 may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), off-the-shelf programmable gate arrays, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0081] The memory 31 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 31 may also be an external storage device of the electronic device, such as a plug-in hard disk equipped on the electronic device, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory 31 may also include both the internal storage unit and the external storage device of the electronic device. The memory 31 is used to store the computer program and other programs and data required by the electronic device. The memory 31 may also be used to temporarily store the data that has been output or will be output.

[0082] It should be noted that for the convenience and brevity of description, the structure of the above-mentioned electronic device may also refer to the specific description of the structure in the method embodiment, which will not be elaborated here.

[0083] Those skilled in the art can clearly understand that for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiment, which will not be elaborated here.

[0084] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not elaborated or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0085] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0086] In the embodiments provided in the present application, it should be understood that the disclosed device / electronic device and method can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.

[0087] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0088] In addition, in each embodiment of the present application, the functional units can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0089] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above method embodiments of the present application, it can also be completed by a computer program instructing relevant hardware. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0090] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A processing method for a timer, characterized in that, Including: In response to a first thread receiving a timing task, send a message to a second thread and control the first thread to wait; In response to the second thread receiving the message, control a timer to start through the second thread and control the first thread to continue running; When the timing of the timer ends, execute a code block associated with the timer, and when the code block is executed, complete the timing task.

2. The processing method of the timer according to claim 1, characterized in that, The controlling the first thread to wait includes: Create an event object, and the event object is associated with the timer; Set the event state of the event object to a first state, and the first state is used to indicate that the first thread waits.

3. The processing method of the timer according to claim 2, wherein The controlling the first thread to continue running includes: Update the event state of the event object to a second state, and the second state is used to indicate that the first thread continues running.

4. The processing method of the timer according to any one of claims 1-3, characterized in that, During the process of executing the code block associated with the timer, it further includes: If the object called when the code block is executed includes a mutex object, obtain the state of the mutex object; If the state of the mutex object is an idle state, enter the critical section where the mutex object is located to execute code to call the mutex object.

5. The processing method of the timer according to any one of claims 1-3, characterized in that The sending a message to the second thread includes: Send a message to the second thread according to the thread handle of the second thread.

6. The processing method of the timer according to any one of claims 1-3, characterized in that, After the code associated with the timer is executed, it further includes: Turn off the timer through the second thread.

7. The processing method of the timer according to any one of claims 1-3, characterized in that, The timing task is used to initiate a vehicle diagnostic instruction.

8. A processing device for a timer, characterized in that, The processing device of the timer includes: A task response unit, configured to, in response to a first thread receiving a timing task, send a message to a second thread and control the first thread to wait; A message processing unit, configured to, in response to the second thread receiving the message, control a timer to start through the second thread and control the first thread to continue running; A timer control unit, configured to, when the timing of the timer ends, execute a code block associated with the timer, and when the code block is executed, complete the timing task.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the processing method of the timer according to any one of claims 1 to 7.

10. A computer program product, characterized in that, Including a computer program, when the computer program is run, the processing method of the timer according to any one of claims 1 to 7 is executed.