Thread management method, electronic equipment and storage medium
By optimizing thread management, and reasonably destroying or merging threads according to the device registration status, the lag and crash problems caused by excessive thread resource usage in electronic devices are solved, and the user experience and registration efficiency are improved.
Patent Information
- Application Number
- CN202310788834.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2024-12-31
AI Technical Summary
In electronic devices, high-occupancy thread resources cause the device to stutter, run slowly and even crash, affecting the user experience.
By destroying unnecessary threads or dynamically merging threads according to the device registration status, reducing the number of registration-related threads and reducing resource usage, and using reasonable startup and destruction strategies for device registration threads, message sending and receiving threads and message processing threads to optimize thread management.
It effectively alleviates the resource shortage on the device, reduces lag and slow operation, improves the user experience, and improves the device registration efficiency.
Smart Images

Figure CN119225913A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a thread management method, an electronic device and a storage medium. Background Art
[0002] With the rapid development of network technology, various electronic devices have emerged widely, such as smart curtains, smart switches, smart kettles, etc. The terminal device can establish a communication connection with the electronic device and control the electronic device so that the electronic device can perform a preset function.
[0003] In the related art, during the use of electronic devices, if the thread resource occupancy of some functions on the IoT device is relatively high, the remaining available resources of the electronic device will be relatively small, which may cause other threads to fail to run or cause the electronic device to become stuck or run slowly; it may even cause device crashes, which will result in a poor user experience of the electronic device. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a thread management method, an electronic device and a storage medium, which can destroy some unnecessary threads according to the registration status of the electronic device, or dynamically merge some threads; the number of registration-related threads and the occupation of electronic device resources can be reduced; in this way, the phenomenon of freezes and slow operation on the electronic device can be reduced, and the user experience can be improved.
[0005] In a first aspect, a thread management method is provided, which can be applied to an electronic device, which can be some Internet of Things devices, such as smart air conditioners, smart screens, etc.; the electronic device can also be some wearable devices, such as smart watches, smart bracelets, etc. The electronic device includes: a device registration thread, a message sending and receiving thread, and a message processing thread. In the method, in response to the electronic device detecting that the electronic device is not registered, the electronic device starts the device registration thread on the electronic device; and the message sending and receiving thread and the message processing thread on the electronic device are in an unstarted state. Afterwards, the electronic device registers with the server through the device registration thread. Among them, the electronic device is not registered can be understood as the electronic device is not registered on the above-mentioned server, or the registration of the electronic device on the above-mentioned server has expired.
[0006] In the first aspect, the electronic device can start the device registration thread required for the electronic device registration during the electronic device registration process, and not start the message receiving and sending thread and the message processing thread not required for the electronic device registration. In this way, the number of threads existing simultaneously on the electronic device can be reduced, and the peak value of the electronic device resource occupation can be reduced. The phenomenon of freezing and slow operation on the electronic device can be alleviated, and the user experience can be improved.
[0007] In a possible design of the first aspect, the thread management method further includes: in response to the electronic device registering successfully through the device registration thread, the electronic device destroys the device registration thread. After that, the electronic device starts the message sending and receiving thread and the message processing thread. In this way, after the electronic device registers successfully with the server, the message sending and receiving and message processing threads are started after destroying the device registration thread. The number of threads existing simultaneously on the electronic device can be reduced, and the peak value of resource occupancy on the electronic device can be further reduced. The phenomenon of freezing and slow operation on the electronic device can be further alleviated, and the user experience can be improved.
[0008] In a possible design of the first aspect, in response to the electronic device detecting that the electronic device is not registered, the electronic device starts the device registration thread on the electronic device, which may include: in response to the electronic device detecting that the electronic device is not registered; at this time, if the message processing thread and the message receiving and sending thread on the electronic device are in the started state, then after the electronic device destroys the message processing thread and the message receiving and sending thread, the electronic device starts the device registration thread on the electronic device. In this design, if the registration of the electronic device expires during the use of the electronic device, the user will not use the message receiving and sending thread and the message processing thread on the electronic device. Therefore, in the unregistered state of the electronic device, destroying these two threads can reduce the occupation of electronic device resources, and can further alleviate the phenomenon of freezing and slow operation on the electronic device.
[0009] In a possible design of the first aspect, in response to the electronic device detecting that the electronic device is not registered, the electronic device starts a device registration thread on the electronic device, which may include: when the electronic device is in a remote communication mode, in response to the electronic device detecting that the electronic device is not registered, the electronic device starts a device registration thread on the electronic device. It is understandable that if the electronic device is always in a near field communication mode, the user may not use the remote communication function of the electronic device. The electronic device may not register the device with the server. In this design, after determining that the electronic device is in a remote mode, it is determined whether the electronic device is registered; thereafter, it is determined whether to start the device registration thread; in this way, resources on the electronic device can be saved according to the user's usage pattern of the electronic device; the user's experience of using the electronic device can be improved.
[0010] In a possible design of the first aspect, the electronic device registers the device with the server through the device registration thread, which may include: the electronic device obtains account information, and the device registration thread on the electronic device sends the account information to the server, so that the server sends the registration information to the electronic device when the account information is verified. Afterwards, the device registration thread on the electronic device receives the registration information sent by the server. Next, the device registration thread on the electronic device sends the device identification of the electronic device to the server, so that the server sends the registration pass identification to the electronic device when the device identification is verified. Then, the device registration thread on the electronic device receives the registration pass identification sent by the server.
[0011] In a possible design of the first aspect, the electronic device obtaining the account information may include: the electronic device obtaining the account information input by the user on the electronic device, or the electronic device receiving the account information sent by the terminal device, or the electronic device searching for the account information from the memory.
[0012] In a possible design of the first aspect, the electronic device is registered on the server through a device registration thread on the electronic device, which may include: the device registration thread on the electronic device sends the device identification and registration information of the electronic device to the server, so that the server sends a registration pass identifier to the electronic device when verifying that the device identification and the registration information are passed. Wherein, the above registration information may be from a terminal device, and is obtained by the terminal device from the server. Afterwards, the device registration thread receives the registration pass identifier sent by the server. In this design, if the communication quality between the electronic device and the server is not good, the terminal device can obtain the registration information from the server, and then send the registration information to the electronic device. In this way, by reducing the number of communications between the electronic device and the server, the slow registration caused by the low communication quality between the electronic device and the server can be alleviated; the registration efficiency of the electronic device can be improved, and the user experience can be improved.
[0013] In a possible design of the first aspect, the electronic device detecting that the electronic device is not registered may include: the electronic device searches for a registration pass identifier; if the electronic device cannot search for the registration pass identifier, determining that the electronic device is detected to be unregistered.
[0014] In a possible design of the first aspect, the electronic device searching for a registration pass identifier may include: searching for a registration pass identifier through a scheduled task of the electronic device. In this design, since the scheduled task may be a task in the operating system of the electronic device, it will not occupy additional resources of the electronic device; thus, the peak value of resource occupancy on the electronic device can be further reduced, and the phenomenon of freezing and slow operation on the electronic device can be alleviated.
[0015] In a possible design of the first aspect, the electronic device starts the message sending and receiving thread and the message processing thread, which may include: the electronic device first starts the message processing thread and then starts the message sending and receiving thread. In this design, by starting the message processing thread first, the control message sent by the server can be processed in a timely manner to execute the function indicated by the message.
[0016] In the second aspect, the present application provides another thread management method, which can be applied to electronic devices, which can be some Internet of Things devices, such as smart switches, smart sockets, etc.; the electronic devices can also be some wearable devices, such as smart watches, smart bracelets, etc. The electronic device includes a message sending and receiving thread and a message processing thread. In this method, the electronic device starts the message sending and receiving thread and the message processing thread on the electronic device. Afterwards, the message sending and receiving thread on the electronic device receives the registration information, and the message processing thread on the electronic device obtains the device identification of the electronic device. Next, the message processing thread on the electronic device sends the device identification to the message sending and receiving thread. Then, the message processing thread on the electronic device sends the registration information and the device identification to the server, so that the server sends the registration pass identification to the electronic device when the registration information and the device identification are verified; then, the message sending and receiving thread on the electronic device receives the registration pass identification sent by the server.
[0017] In the second aspect, the electronic device can dynamically merge the device registration thread into the message processing thread and the message receiving and sending thread, so that the device registration thread does not need to be started on the electronic device. This can reduce the number of threads that exist simultaneously on the electronic device and reduce the peak value of electronic device resource usage. It can alleviate the phenomenon of freezing and slow operation on the electronic device and improve the user experience.
[0018] In a possible design of the second aspect, the message sending and receiving thread receives registration information, including: the message sending and receiving thread receives registration information from a terminal device, where the registration information is obtained by the terminal device from a server; or the message sending and receiving thread receives the registration information from a server.
[0019] In a possible design of the second aspect, the electronic device starts the message receiving and sending thread and the message processing thread, which may include: the electronic device first starts the message receiving and sending thread, and then starts the message processing thread. In this design, by setting the start sequence of the message receiving and sending threads, the electronic device can receive the registration information sent by the terminal device in a timely manner, which can shorten the registration time of the electronic device and improve the registration efficiency of the electronic device.
[0020] In a third aspect, an electronic device is provided, which has the function of implementing the method described in the first aspect and any possible design of the first aspect; or, the electronic device has the function of implementing the method described in the second aspect and any possible design of the second aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. For example, a business module, a system module, etc.
[0021] In a fourth aspect, an electronic device is provided, which may include a memory and one or more processors, wherein the memory is coupled to the processor; wherein computer program code is stored in the memory, and the computer program code includes computer instructions; when the computer instructions are executed by the processor, the electronic device executes the method described in the first aspect and any possible design of the first aspect; or, the electronic device executes the method described in the second aspect and any possible design of the second aspect.
[0022] In a fifth aspect, a computer-readable storage medium is provided, which stores instructions, and when the computer-readable storage medium is run on an electronic device, the electronic device can execute the method described in the first aspect and any possible design of the first aspect; or, the electronic device can execute the method described in the second aspect and any possible design of the second aspect.
[0023] In a sixth aspect, a computer program product comprising instructions is provided, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible design of the first aspect; or, enables the electronic device to execute the method described in the second aspect and any possible design of the second aspect.
[0024] Among them, the technical effects brought about by any design method in the third to sixth aspects can refer to the technical effects brought about by the different design methods in the above-mentioned first aspect and the different design methods in the second aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A schematic diagram of the structure of a communication system provided in an embodiment of the present application;
[0026] Figure 2 A schematic diagram of the hardware structure of a terminal device provided in an embodiment of the present application;
[0027] Figure 3 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0028] Figure 4A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0029] Figure 5 A schematic diagram of an application interface of a terminal device provided in an embodiment of the present application;
[0030] Figure 6 A flowchart of a thread management method provided in an embodiment of the present application;
[0031] Figure 7 A schematic diagram of a setting interface of an electronic device provided in an embodiment of the present application;
[0032] Figure 8 A schematic diagram of a pop-up window interface of an electronic device provided in an embodiment of the present application;
[0033] Fig. 9 A flowchart of another thread management method provided in an embodiment of the present application;
[0034] Fig.10 A flowchart of another thread management method provided in an embodiment of the present application;
[0035] Fig.11 A schematic diagram of a usage scenario of an electronic device provided in an embodiment of the present application;
[0036] Fig.12 A schematic diagram of a login interface of an electronic device provided in an embodiment of the present application;
[0037] Fig.13 A schematic diagram of a login interface of a terminal device provided in an embodiment of the present application;
[0038] Fig.14 A flowchart of another thread management method provided in an embodiment of the present application;
[0039] Fig.15 A flowchart of another thread management method provided in an embodiment of the present application;
[0040] Fig.16 A flowchart of another thread management method provided in an embodiment of the present application;
[0041] Fig.17 A schematic diagram of a login interface of another terminal device provided in an embodiment of the present application;
[0042] Fig.18 A schematic diagram of the hardware structure of a thread management device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the present application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship, for example, A / B can represent A or B; "and / or" in the present application is only a kind of association relationship describing the associated objects, indicating that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. And, in the description of the embodiments of the present application, unless otherwise specified, "multiple" refers to two or more than two. "At least one of the following" or its similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit the difference.
[0044] Meanwhile, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete manner for ease of understanding.
[0045] With the rapid development of network technology, various electronic devices have appeared widely, such as smart refrigerators, smart kettles, smart sockets, smart curtains, smart switches, smart watches, smart screens, etc. During the use of electronic devices, electronic devices can be registered, so that the terminal device can send a control message to the electronic device through the server to enable the electronic device to perform the function indicated by the message. Exemplarily, the terminal device can send a control message to the smart switch through the server; in this way, the user can remotely turn on or off the line connected to the smart switch. Another example is that the terminal device can send a data message (for example, a picture data message, a text data message, a voice data message, etc.) to a smart watch; in this way, the smart watch can perform the function indicated by the data message (such as displaying pictures, displaying text, playing voice, storing pictures, etc.).
[0046] In some scenarios, when an electronic device is in use, multiple threads will exist on the electronic device at the same time; the simultaneous existence of multiple threads will occupy a lot of resources of the electronic device (such as processor resources, memory resources, etc.), which will cause the electronic device to freeze and run slowly. Especially for some electronic devices with weak processor performance and small memory (such as IoT devices, lightweight IoT devices, etc.), this freeze and slow running phenomenon will be more obvious.
[0047] For example, during the registration process of an electronic device, three threads, namely, a message sending and receiving thread, a message processing thread, and a device registration thread, will exist on the electronic device at the same time. These three threads will occupy the memory resources and processor resources of the electronic device, which will lead to resource shortages on the electronic device. This will cause the electronic device to freeze and run slowly. Especially for some electronic devices with weak processor capabilities and small memory space; since the above three threads occupy the resources of the electronic device at the same time, the electronic device will experience serious freezes and slow operation. Even in some scenarios, if the service threads on the electronic device (such as the display thread of a smart watch, the water temperature control thread of a smart kettle, etc.) use too many resources, if the electronic device registers the device at this time, the message sending and receiving thread, the message processing thread, the device registration thread, and the service thread will occupy the resources of the electronic device at the same time, which may cause the electronic device to be seriously insufficient in resources. This will then cause the electronic device to crash and fail to operate.
[0048] In view of this, an embodiment of the present application provides a thread management method, in which some unnecessary threads can be destroyed or some threads can be dynamically merged according to the registration status of the electronic device. In this way, the number of threads existing simultaneously on the electronic device can be reduced, and the resource shortage on the electronic device can be alleviated. In addition, since the number of threads existing simultaneously on the electronic device is reduced, the peak value of resource occupancy on the electronic device will be reduced, which can alleviate the phenomenon of slow running of the electronic device and improve the user experience.
[0049] The thread management method provided in the embodiment of the present application can be applied to the daily use of electronic devices by users, and is particularly applicable to the registration process of electronic devices. When a user is using an electronic device and needs to register the electronic device, the electronic device can use the thread management method provided in the embodiment of the present application to manage the threads on the electronic device during the registration process.
[0050] Exemplarily, the thread management provided by the embodiment of the present application can be applied to Figure 1 In the communication system shown. Figure 1, the electronic device 200 can directly establish a communication connection with the terminal device 100; thus, the electronic device 200 can receive the control message sent by the terminal device 100; thereafter, the electronic device 200 can execute the function indicated by the message based on the received message. Figure 1 , the electronic device 200 can also indirectly establish a communication connection with the terminal device 100 through the server 300 as a relay; in this way, the electronic device 200 can receive the control message sent by the terminal device 100 through the server 300; thereafter, the electronic device 200 can execute the function indicated by the message based on the received message.
[0051] It should be noted that Figure 1 A possible communication system architecture is shown in the embodiment of the present application. Figure 1 The communication architecture shown may also have other forms. For example, the communication system may include an electronic device 200 and a terminal device 100, and the two establish a communication connection. Alternatively, the communication system may also include a server 300, an electronic device 200, and a terminal device 100. The electronic device 200 establishes a communication connection with the terminal device 100 through the server 300 as a relay. The embodiment of the present application does not impose any restrictions on this.
[0052] Exemplarily, the electronic devices in the embodiments of the present application may be some Internet of Things (IoT) devices, such as smart switches, smart desk lamps, smart kettles, smart sockets, smart home devices and other smart home devices with communication capabilities; the electronic devices may also be some wearable devices, such as smart watches, smart bracelets, smart glasses and other devices with communication capabilities; they may also be some electronic devices, such as mobile phones, tablet computers, laptops, personal computers (personal computers, PCs), car computers and other electronic devices with communication capabilities. In addition, the electronic devices may also be some augmented reality (AR) / virtual display (VR) devices with communication capabilities. The embodiments of the present application do not impose any restrictions on the product form of the electronic devices.
[0053] For example, the terminal devices in the embodiments of the present application may be some terminal devices with communication capabilities, such as mobile phones, tablet computers, laptop computers, personal computers (PCs), car computers, etc.; and the terminal devices may also be some AR / VR devices with communication capabilities, etc. The embodiments of the present application do not impose any restrictions on the product form of the terminal devices.
[0054] Exemplarily, the server in the embodiment of the present application may be a cloud server, a heterogeneous server, a cluster server, a virtual server, etc. The embodiment of the present application does not impose any restrictions on the product form of the server.
[0055] Exemplarily, the communication method between the terminal device 100 and the electronic device 200 may be some near field communication methods; for example, Bluetooth communication, near field communication (NFC), infrared communication, or WLAN communication based on wireless local area networks (WLAN) technology (such as wireless fidelity (Wi-Fi) communication), Zigbee communication, etc. Also, the communication method between the terminal device 100 and the server 300 may be some remote communication methods; for example, 3G communication based on the third generation (3G) communication technology, or 4G communication based on the fourth generation (4G) communication technology, or 5G communication based on the fifth generation (5G) communication technology, etc. Also, the communication method between the electronic device 200 and the server 300 may also be some remote communication methods: for example, 3G communication based on 3G communication technology, or 4G communication based on 4G communication technology, or 5G communication based on 5G technology, etc. This application does not impose any restrictions on the communication method between the terminal device 100 and the electronic device 200, the communication method between the terminal device 100 and the server 300, and the communication method between the electronic device 200 and the server 300.
[0056] For example, Figure 2 A schematic diagram of the hardware structure of the terminal device 100 is shown.
[0057] The terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
[0058] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0059] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a central processing unit (CPU), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0060] The controller may be the nerve center and command center of the terminal device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0061] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0062] The wireless communication function of the terminal device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0063] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0064] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the terminal device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0065] For example, in some embodiments of the present application, the terminal device 100 can establish a 4G connection with the server 300 through the mobile communication module 105, the antenna, the wireless communication module 160, etc. Alternatively, the terminal device 100 can also establish a Bluetooth connection with the electronic device 200 through the mobile communication module 105, the antenna, the wireless communication module 160, etc.
[0066] Figure 3 A schematic diagram of the hardware structure of the electronic device 200 in an embodiment of the present application is shown.
[0067] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 200. In other embodiments of the present application, the electronic device 200 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0068] like Figure 3 As shown, the electronic device 200 may include a processor 201, a memory 202, a wireless communication module 203, an antenna 204, a power switch 205, a USB communication processing module 206, etc. Among them: the processor 201 can be used to read and execute computer-readable instructions. In a specific implementation, the processor 201 may mainly include a controller, an arithmetic unit and a register. Among them, the controller is mainly responsible for decoding instructions and sending control signals for operations corresponding to the instructions. The arithmetic unit is mainly responsible for saving register operands and intermediate operation results temporarily stored during the execution of instructions. In a specific implementation, the hardware architecture of the processor 201 may be an application-specific integrated circuit (ASIC) architecture, a MIPS architecture, an ARM architecture or an NP architecture, etc.
[0069] In some embodiments, the processor 201 may be configured to parse signals received by the wireless communication module 203 , such as a query request, a paging request, etc. sent by a terminal device.
[0070] The memory 202 is coupled to the processor 201 and is used to store various software programs and / or multiple sets of instructions. In a specific implementation, the memory 202 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. The memory 202 may store an operating system, such as uCOS, VxWorks, RTLink, and other embedded operating systems. The memory 202 may also store a communication program, which may be used to communicate with the terminal device 100.
[0071] Among them, the wireless communication module 203 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared communication (IR), 4G / 5G, etc. on the electronic device 200. The wireless communication module 203 can be one or more devices integrating at least one communication processing module. The wireless communication module 203 receives electromagnetic waves via the antenna 204, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 201. The wireless communication module 203 can also receive the signal to be sent from the processor 201, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 204.
[0072] Exemplarily, the electronic device 200 can establish a communication connection with the terminal device 100 through the processor 201, the wireless communication module 203 and the antenna 204, etc.; or, establish a communication connection with the server 300 through the processor 201, the wireless communication module 203 and the antenna 204, etc.
[0073] Antenna 204 can be used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 200 can be used to cover a single or multiple communication frequency bands. In some embodiments, wireless communication module 203 can have one or more antennas. Power switch 205 can be used to control the power supply to electronic device 200. USB communication processing module 206 can be used to communicate with the electronic device 200 through a USB interface ( Figure 3 In some embodiments, the electronic device 200 may further include a serial interface such as an RS-232 interface. The serial interface may be connected to other devices, such as an audio external speaker device such as a speaker, so that the electronic device 200 and the audio external speaker device can collaborate to play audio and video.
[0074] Figure 4 The software structure diagram of the electronic device in the embodiment of the present application is shown. It is understandable that the software structure of different types of electronic devices can be divided in different ways. Each software module will also have different components, and relevant technicians can design according to actual use, and the embodiment of the present application does not impose any restrictions on this.
[0075] The electronic device may include: a business module and a system module (operating system module). Among them, the business module can be understood as being used to execute the preset functions of the electronic device. The business module may include: a product business thread, a device registration thread, a message sending and receiving thread, a message processing thread, and the like. The product business thread can execute the preset functions of the electronic device; for example, a module for a smart switch to execute the on and off functions, a module for a smart kettle to execute the water temperature control, a module for a smart watch to execute the blood oxygen detection function, a module for a smart watch to execute the display function, and the like. The device registration thread can be used to register the electronic device on the server. The message sending and receiving thread can be used to receive, send or cache control messages (such as business control messages, status control messages, query control messages, picture data messages, file data messages, voice data messages, etc.) sent by the server to the electronic device. The message processing thread can be used to process messages sent by the server, or generate messages sent to the server (such as the current status and power of the electronic device; as well as control messages, data messages, etc.). In some embodiments, the device registration thread, the message sending and receiving thread, and the message processing thread in the business module can be encapsulated into a remote communication submodule (tool). In this way, when developing a business module, the developer can directly load the encapsulated remote communication submodule to enable the business module to have remote communication capabilities. In addition, the system module can be understood as providing some basic functions for electronic devices; such as thread management function, power management function, timing function, etc.; some basic protocols, such as Bluetooth protocol, hypertext transfer protocol (HTTP) protocol, etc. Some basic drivers, such as battery driver, audio driver, sensor driver, etc.
[0076] Exemplarily, the electronic device 200 can use the Bluetooth protocol to receive the control instruction sent by the terminal 100 through the antenna 204 and the wireless communication module 203. Then the electronic device 200 puts the control instruction into the message transceiving thread; then the message transceiving thread forwards the control instruction to the message processing thread. The message processing thread parses the control instruction and sends the parsed control instruction to the product service thread. In this way, the product service thread will execute the preset function based on the parsed control instruction.
[0077] As another example, the electronic device 200 can use the HTTP protocol to receive the control instruction sent by the server through the antenna 204 and the wireless communication module 203. Then the electronic device 200 puts the control instruction into the message transceiving thread; then the message transceiving thread forwards the control instruction to the message processing thread. The message processing thread parses the control instruction and sends the parsed control instruction to the product service thread. In this way, the product service thread will execute the preset function based on the parsed control instruction.
[0078] It can be understood that the connection modes of the electronic device 200 (such as a smart watch, a smart switch, a smart socket, etc.) may include: a near-field connection mode and a remote connection mode.
[0079] Among them, the electronic device (such as a smart watch) is in a remote connection mode (remote communication mode), which can be understood as the electronic device can communicate with the terminal device (such as a mobile phone) through the server as a relay. That is to say, the electronic device establishes a remote connection with the server. Exemplarily, the smart watch can establish a remote connection with the server through the hypertext transfer protocol (HTTP) protocol; or, the smart watch can also establish a remote connection through the message queuing telemetry transport (MQTT) protocol. Exemplarily, the smart watch can establish a remote connection with the server through the long-term evolution (LTE) network. The embodiment of the present application does not impose any restrictions on the protocol used for remote communication between the smart watch and the server, and the method of remote communication.
[0080] For example, the smart watch can access the LTE network provided by the network operator through the electronic subscriber identification module (eSIM) card of the smart watch to establish a communication connection with the server. In this way, the smart watch will be in remote connection mode.
[0081] Furthermore, the electronic device being in the near field connection mode can be understood as the electronic device can establish a near field communication connection with a terminal device (such as a mobile phone) through a near field communication method. The near field communication method can be Bluetooth communication, wireless LAN communication, infrared communication, NFC communication, etc. Exemplarily, a smart watch can establish a near field connection with a mobile phone through a Bluetooth protocol (such as Bluetooth protocol version 4.1, Bluetooth protocol version 4.2, etc.).
[0082] Below, we will take the example of a smart watch establishing a near-field connection with a mobile phone through the Bluetooth protocol to briefly introduce the process of establishing a near-field connection between a smart watch and a mobile phone.
[0083] When the mobile phone and the smart watch have not established a Bluetooth connection, after the mobile phone turns on the Bluetooth function, the mobile phone can send an inquiry request to the surrounding area. When the smart watch is in the inquiry Bluetooth scanning state, the smart watch can scan the inquiry request sent by the mobile phone. In response to the scanned inquiry request, the smart watch can send an inquiry response to the mobile phone, so that the mobile phone obtains the smart watch as a pairable electronic device option. When the user selects the device option of the smart watch, the mobile phone can send a paging request to the smart watch. The smart watch can monitor the paging request of the mobile phone at a certain frequency within a fixed time window at a fixed interval. After monitoring the paging request of the mobile phone, the smart watch can send a slave paging response to the mobile phone in the next time slot (time window). After receiving the slave paging response of the smart watch, the mobile phone can send a master paging response to the smart watch in the next time slot. Based on this, a Bluetooth connection is established between the mobile phone and the smart watch.
[0084] For example, the mobile phone can search for the smart watch through the Smart Space APP and establish a Bluetooth connection with the smart watch. In some embodiments, the process can be as follows:
[0085] When the mobile phone is not connected to the smart watch, after the Bluetooth function of the mobile phone is turned on, the device discovery module of the mobile phone will broadcast (advertising) and send a broadcast event (advertising event). The broadcast event will include the above query request. The mobile phone obtains the smart watch as a pairable smart watch option. Among them, the broadcast event (advertisingevent) is to send one or more broadcast packets (for example, ADV_IND broadcast packets) at a preset broadcast interval. Among them, the broadcast packet can be sent simultaneously on one or more radio frequency channels. In one possible implementation, a device management application is provided on the mobile phone. After the mobile phone starts the Bluetooth management application, in response to the user's operation, the mobile phone and the smart watch establish a Bluetooth connection. Exemplarily, the Bluetooth management application can be a smart space APP; see Figure 5 , Figure 5 Part (a) in the figure shows a display interface of the Smart Space APP in the mobile phone. There is an "Add Device" control on the display interface. When the user clicks the control, the Bluetooth function of the mobile phone is turned on for the user. The device discovery module of the mobile phone will broadcast and send broadcast events. The display interface can jump to Figure 5 The interface shown in part (b) indicates that the phone starts scanning and discovers the smart watch.
[0086] If the smartwatch turns on its own Bluetooth function at this time, the smartwatch will scan on the above one or more radio frequency channels. When the smartwatch scans the broadcast packet sent by the mobile phone, the smartwatch will send a query response to the mobile phone. In response to the mobile phone receiving the query response, the mobile phone can obtain the smartwatch as a pairable smartwatch option. For example, see again Figure 5 , Figure 5 In part (c) of the figure, the mobile phone displays the scanned smart watch, but the mobile phone and the smart watch are not connected at this time. Figure 5 As shown in part (d) of , if the user selects the smart watch, the mobile phone will send a paging request to the smart watch, requesting to establish a Bluetooth connection with the smart watch. For example, in response to the user selecting the device option of the smart watch, the mobile phone can send a paging request to the smart watch. The smart watch can monitor the paging request of the mobile phone at a certain FM frequency within a fixed time window at fixed intervals. After monitoring the paging request of the mobile phone, the smart watch can send a slave device paging response to the mobile phone in the next time slot. After receiving the slave device paging response from the smart watch, the mobile phone can send a master device paging response to the smart watch in the next time slot. Based on this, a Bluetooth connection is established between the mobile phone and the smart watch, and the smart watch will be in near field connection mode.
[0087] For example, the user can also scan the QR code on the smart watch through the mobile phone to establish a Bluetooth connection with the smart watch.
[0088] It should be pointed out that those skilled in the art can design the process of establishing a Bluetooth connection between a smart watch and a mobile phone according to actual usage conditions, and the embodiments of the present application do not impose any restrictions on this.
[0089] Hereinafter, the thread management method provided by the embodiment of the present application will be specifically described in conjunction with the accompanying drawings and application scenarios. The thread management method provided by the embodiment of the present application can be applied to electronic devices with independent registration capabilities, and can also be applied to electronic devices without independent registration capabilities. Among them, electronic devices with independent registration capabilities can be considered as electronic devices that can independently complete registration on the server without the assistance of other devices (such as terminal devices).
[0090] Exemplarily, an electronic device with independent registration capability may be an electronic device with a user input module. For example, an electronic device with a user input module such as a button, a touch sensor, or a microphone; in this way, a user can input account information (such as a user account, registration credentials, etc.) to the electronic device through a button or a touch sensor on the electronic device, and then the electronic device can register with the server through the registration information. For another example, an electronic device with independent registration capability may also be an electronic device with a voice user input module such as a microphone; in this way, a user can input a user account through a voice user input module such as a microphone on the electronic device, and then the electronic device can register with the server through the user account. Exemplarily, the above-mentioned electronic device with independent registration capability may be some wearable devices (for example, smart watches, smart bracelets, etc.), some IoT devices, such as (smart home devices, smart speakers, etc.), or some electronic devices (for example, smart screens, tablets, etc.), etc.
[0091] Furthermore, electronic devices that do not have independent registration capabilities can be understood as electronic devices that need to be assisted by other devices (such as terminal devices) to complete registration on the server. Such electronic devices may not have a user input module, and other devices are required to send account information (such as user account, registration credentials, etc.) to the electronic device, and then the electronic device registers with the server based on the received account information.
[0092] First, we will Figure 1 In the communication system shown, taking the example of the terminal device 100 being a mobile phone, the electronic device 200 being a smart watch with independent registration capability, and the server 300 being a cloud server, the thread management method provided in the embodiment of the present application is introduced in detail.
[0093] See also Figure 6 The thread management method provided in the embodiment of the present application may include steps S101-S104.
[0094] In some embodiments, the thread management method provided by the embodiments of the present application may further include: step S100.
[0095] S100. The smart watch performs remote communication initialization.
[0096] It can be understood that the smart watch performs remote communication initialization, which may include: the smart watch loads the protocol required for remote communication (such as loading the HTTP protocol, loading the MQTT protocol, etc.); and / or threads (such as device registration threads) perform memory application, etc.
[0097] In some embodiments, the user can enable the remote connection mode through the setting interface of the smart watch. After that, the smart watch triggers step S100.
[0098] For example, see Figure 7 , the user can click the setting 701 option on the smart watch 700. In response to the user clicking the setting 701 option on the smart watch 700, the smart watch 700 can display the setting interface 702. In response to the user clicking the "connection setting" option in the setting interface 702, the smart watch 700 can display the connection setting interface 703. In response to the user turning on the "remote mode" button in the connection setting interface 703, the smart watch 700 can turn on the remote connection mode. Afterwards, the smart watch triggers step S100.
[0099] In some embodiments, the user can enable the remote connection mode through the setting interface of the smart watch. When the smart watch is in the remote connection mode, if the smart watch detects that the near field connection is disconnected, the smart watch triggers step S100.
[0100] In some embodiments, the smartwatch can prompt the user to turn on the remote communication mode after detecting that the near-field connection (such as Bluetooth connection) is disconnected. Figure 8 After the smart watch 900 disconnects the near field connection, the smart watch 900 may display a prompt pop-up window 901. In response to the user clicking a confirmation button 902 in the prompt pop-up window 901, the smart watch triggers step S100.
[0101] For example, see Fig. 9 The above step S100 may be to initialize the remote communication submodule of the watch service thread.
[0102] It is understandable that the smartwatch can trigger step S100 at any desired time; for example, step S100 can be triggered before step S101 described below, or before step S102 described below. Relevant personnel can design the triggering time of step S100 according to actual usage needs. And relevant personnel can also design the triggering method of step S100 according to actual usage needs, such as voice prompts, etc. This embodiment of the application does not impose any restrictions on this.
[0103] It is understandable that in some embodiments, for some electronic devices, the remote communication capabilities of these electronic devices may be provided by the system module of the electronic devices, so for these electronic devices, step S100 may not be performed, and they may still have the remote communication capabilities. In other words, for these electronic devices, initialization may not be performed before starting the process related to the remote communication capabilities.
[0104] S101. The smart watch detects that the smart watch is not registered.
[0105] In some embodiments, the above-mentioned smart watch is not registered can be understood as the smart watch is not registered with the server.
[0106] It is understandable that after the smart watch is registered, the server will send a registration pass mark to the smart watch. In this way, when the smart watch communicates with the server later, both can use the registration pass mark to perform identity authentication, security authentication, etc.
[0107] In some embodiments, the smart watch can determine whether the smart watch is registered by searching for a registration pass identifier in the memory. The registration pass identifier may also be referred to as a registration pass flag, a registration pass credential, a registration pass flag, etc. in some embodiments. Exemplarily, the registration pass identifier may have some specific fields. For example, "devIid" and "secret", etc. The smart watch can search for these specific fields in the memory to determine whether the smart watch has been registered.
[0108] In some embodiments, the above-mentioned unregistered smart watch can also be understood as that the registration of the smart watch has expired.
[0109] It is understandable that in some embodiments, the registration pass identifier sent by the server to the smart watch may be time-limited (e.g., 90 days, 200 hours, etc.). When the registration pass identifier expires, the smart watch needs to re-register with the server so that the server sends a new registration pass identifier with time limit to the smart watch.
[0110] In some embodiments, the smartwatch can determine whether the registration pass identifier has expired by calculating whether the registration pass identifier has reached the validity period. For example, suppose the smartwatch receives a registration pass identifier with a validity period of 100 hours. The smartwatch will record the usage time of the smartwatch; if the usage time of the smartwatch is greater than or equal to 100 hours after receiving the registration pass identifier, the smartwatch determines that the registration pass identifier has expired, and the smartwatch can delete the registration pass identifier from the internal memory.
[0111] In some embodiments, the server may also send a registration expiration instruction to the smart watch, and the smart watch deletes the registration pass identifier from the memory in response to receiving the registration expiration instruction.
[0112] In some embodiments, the smart watch can periodically query whether the smart watch is registered through a registration query unit (e.g., a timed task). The timed task can be a timed task in the operating system (e.g., a system module) of the smart watch. The timed task can trigger some preset actions when the preset timing time is reached. It should be understood that the timed task can be a timed task in the operating system of the smart watch, and the timed task will use the resources that have been configured in the operating system. In other words, the task will not occupy additional processor resources and memory resources on the smart watch.
[0113] In some embodiments, the smart watch may also query in real time whether the smart watch is registered.
[0114] In some embodiments, it is considered that the smart watch may receive a registration expiration instruction sent by the server when using the remote communication function. After that, the smart watch will be in an unregistered state. In this scenario, when it is detected in step S101 that the smart watch is not registered, it can also be determined whether the message sending and receiving thread and the message processing thread on the smart watch are in the started state. If the message sending and receiving thread and the message processing thread on the smart watch are in the started state, the smart watch destroys the message sending and receiving thread and the message processing thread.
[0115] It is understandable that if the smart watch is in an unregistered state, the remote mode of the smart watch is not used by the user; that is, the message sending and receiving thread and the message processing thread will not be used by the smart watch when the smart watch is unregistered. Therefore, these two threads can be destroyed when the smart watch is unregistered, which can save resources on the smart watch.
[0116] In some embodiments, see Fig.10 The above step S101 may include steps S101a1 - S101a2 .
[0117] S101a1. In response to the smart watch switching from the near field connection mode to the remote connection mode, the watch service thread starts the registration query unit.
[0118] In some embodiments, the registration query unit may be located in the business module of the smart watch. The registration query unit may also be a timer task in the system module. The present application embodiment does not impose any limitation on this.
[0119] In some embodiments, the watch service thread may determine, through the communication protocol used by the smart watch, that the smart watch switches from the near field connection mode to the remote connection mode.
[0120] Exemplarily, if the communication protocol used by the smart watch is switched from the Bluetooth protocol to the HTTP protocol, it is determined that the smart watch is switched from the near field connection mode to the remote connection mode.
[0121] In some embodiments, the watch service thread may also determine, through the communication object of the smart watch, whether the smart watch switches from the near field connection mode to the remote connection mode.
[0122] Exemplarily, if the communication partner of the smart watch is switched from the mobile phone to the server, it is determined that the smart watch is switched from the near field connection mode to the remote connection mode.
[0123] In some embodiments, the watch service thread may also determine that the smart watch switches from the near field connection mode to the remote connection mode by detecting that the smart watch disconnects the near field communication connection.
[0124] Exemplarily, if the smart watch disconnects the Bluetooth connection with the mobile phone, it is determined that the smart watch switches from the near-field connection mode to the remote connection mode.
[0125] For example, see Fig.11 The scenario shown. User 400 uses smart watch 401 to establish a Bluetooth connection with mobile phone 402 indoors, and smart watch 401 is in near field connection mode. Afterwards, user 400 moves from indoors to outdoors, and smart watch 401 disconnects the Bluetooth connection with mobile phone 402. At this time, smart watch 401 detects the switch from near field connection mode to remote connection mode, and smart watch 401 starts a scheduled task.
[0126] S101a2. In response to the registration query unit reaching a preset trigger condition, the registration query unit detects that the smart watch is not registered.
[0127] Among them, the trigger condition of the registration query unit may be reaching a preset timing time, or receiving a trigger indication from the user on the smart watch. It is understandable that the preset timing time may be 1 second, 5 seconds, 20 seconds, etc. The trigger indication from the user on the smart watch may be that the user uses the remote communication function on the smart watch; for example, the user instructs the smart watch to send a control message to the cloud server, the user instructs the smart watch to receive a control message from the cloud service, etc. Relevant technicians may set it according to actual usage needs, and the embodiments of the present application do not impose any restrictions on this.
[0128] For example, in response to the registration query unit reaching a preset timing time, the registration query unit queries the memory of the smart watch whether there is a registration pass mark. If there is no registration pass mark in the memory, the registration query unit determines that the smart watch is detected to be unregistered.
[0129] S102. The smart watch starts the device registration thread, but does not start the message sending and receiving thread and the message processing thread.
[0130] At this time, the message sending and receiving thread and the message processing thread on the smart watch are not started. It is understandable that if the smart watch has not been registered on the server, the smart watch does not use the message sending and receiving thread and the message processing thread to receive messages. Therefore, when the smart watch is not registered, the smart watch can only start the device registration thread; at this time, the message sending and receiving thread and the message processing thread on the smart watch are not started. In this way, the number of threads that exist simultaneously on the smart watch during registration can be reduced, and the peak resource usage on the smart watch during registration can be reduced. It can alleviate the phenomenon of freezes and slow operation on smart watches. For some lightweight IoT devices, the number of threads that exist simultaneously on smart watches is reduced, which can reduce the occurrence of device crashes on smart watches.
[0131] It is understandable that the smartwatch can start the device registration thread, and the device registration thread performs device registration; thus, after the registration is successful, the smartwatch can receive the message sent by the server and execute the function indicated by the message. In some embodiments, the device registration thread can be started by the above-mentioned registration query unit (such as a scheduled task), or the registration query unit can instruct the watch service to start the registration thread, etc. The embodiments of the present application do not impose any restrictions on this.
[0132] In some embodiments, the smartwatch may also determine whether the message sending and receiving thread and the message processing thread on the smartwatch are in the startup state before starting the device registration thread. If the message sending and receiving thread and the message processing thread on the smartwatch are in the startup state, the smartwatch destroys the message sending and receiving thread and the message processing thread, and then starts the device registration thread. In the embodiment of the present application, there is no restriction on the triggering timing for determining whether the message sending and receiving thread and the message processing thread on the smartwatch are in the startup state.
[0133] For example, see again Fig. 9 and Fig.10 The above step S102 may include the following steps S102a1-S102a6.
[0134] S102a1. The registration query unit starts the device registration thread, but does not start the message receiving and sending thread and the message processing thread.
[0135] In some embodiments, the thread can be started by calling a preset interface in the system module on the smart watch, or by some startup functions such as (run function, start function, etc.).
[0136] Exemplarily, the registration query unit can start the device registration thread by calling a preset interface to apply for the memory space required by the device registration thread, allocate the processing resources required by the device registration thread, etc. At this time, the registration query unit does not start the message receiving and sending thread and the message processing thread, that is, the message receiving and sending thread and the message processing thread on the smart watch are not started.
[0137] S102a2. The device registration thread obtains account information.
[0138] Among them, the account information can be in the form of user account and password, user email and password, user mobile phone number and verification code, etc. The embodiment of the present application does not impose any restrictions on the account information.
[0139] In some embodiments, the device registration thread can search for account information from the memory of the smart watch; or, the device registration thread can obtain the account information through user voice input; or, the device registration thread can obtain the account information by displaying an account input interface for the user to input on the smart watch.
[0140] For example, the user can use the voice recognition function of the smart watch to voice input the user account and user password into the smart watch. For example, the user can use the voice wake-up word on the smart watch to turn on the voice input function of the smart watch. After that, the user can voice input the user account and user password.
[0141] For example, see Fig.12 The user can enter the user account and password on the account login interface 1201 of the smart watch; then, the user can click the "Login" button 1202 to log in the user account on the smart watch. In this way, the device registration thread of the smart watch can obtain the user account and password entered by the user on the account login interface 1201.
[0142] In other embodiments, the account information may be input by the user on the mobile phone, sent to the smart watch by the mobile phone through near field communication, and stored in the memory by the smart watch. It is understandable that the user input module (such as the touch screen) of the smart watch may be relatively small, and it may not be very convenient for the user to input the user account on the touch screen of the smart watch. Therefore, the user can log in to the user account on the mobile phone; then, the mobile phone sends the user account logged in by the user to the smart watch. In this way, the convenience of user operation can be increased, and the user experience can be further improved.
[0143] For example, in Fig.12In the illustrated scenario, when the user 400 is indoors, the mobile phone 402 can establish a near field communication connection with the smart watch 401. At this time, the user can send the user account logged in on the mobile phone 402 to the smart watch 401.
[0144] For example, see Fig.13 , the user can log in to the user account in the account login interface 1300 on the device management APP (such as the Smart Space APP) on the mobile phone. The user can log in using the user account (for example, the user's mobile phone number, email address or other account name) and password. In response to the user clicking the "SMS verification code login" option 1301, the mobile phone can display another account login interface 1302. The user can log in to the user account by logging in with the mobile phone number and verification code in the account login interface 1302. After logging in to the user account, the user can view the electronic devices that have established near-field connections on the mobile phone. The user can click the smart watch option 1304 in the device management interface 1303. After that, the device management menu will pop up in the device management interface 1303. In response to the user clicking the "Login Account" option 1305 in the device management menu, the mobile phone sends the user account logged in by the user to the smart watch.
[0145] For example, the mobile phone can send the user account to the smart watch via the Bluetooth protocol, and then the Bluetooth communication module of the smart watch receives the user account sent by the mobile phone; next, the Bluetooth communication module sends the user account to the device registration thread.
[0146] In other embodiments, in response to a user successfully logging in to the above account login interface 1301 or the account login interface 1301, the mobile phone can automatically send the user account logged in by the user to the smart watch.
[0147] S102a3. The smart watch sends the account information to the cloud server 403.
[0148] Exemplarily, in step S102a3, the device registration thread of the smart watch may send the account information to the cloud server to trigger the cloud server to verify the account information.
[0149] S102a4. In response to the cloud server 403 verifying that the account information meets the preset conditions (passed), the cloud server sends registration information to the smart watch.
[0150] Exemplarily, the registration information sent by the cloud server may be received by the device registration thread of the smart watch.
[0151] Among them, the server verifies that the account information meets the preset, which can be understood as the account information sent by the smart watch is valid. A message can be sent to the smart watch through a remote connection later. In some embodiments, the cloud server verifies that the account information meets the preset, which can also be expressed as the cloud server verifies that the account information passes. Exemplarily, the cloud server can determine whether the account information sent by the smart watch meets the preset by comparing the account information in the database with the account information sent by the smart watch. Alternatively, the cloud server can also verify whether the account information meets the preset through some account verification algorithms. The embodiments of the present application are not limited to this.
[0152] And, the registration information can be used to perform subsequent device registration steps, so that the cloud server binds the smart watch to the above account information, so that the cloud server can send messages to the smart watch. Exemplarily, the registration information can be regastID.
[0153] S102a5. The smart watch sends device identification information and registration information to the cloud server 403.
[0154] Exemplarily, in step S102a5, the device registration thread of the smart watch may send the device identification information and the registration information to the cloud server.
[0155] It is understandable that the electronic device will have some device identification information, which may also be referred to as device identification in some embodiments; for example, a personal identification number (PIN) code, a device serial number, etc. After receiving the registration information, the device registration thread may search for the PIN code from the memory and send the PIN code to the cloud server 403. In this way, the cloud server may establish an identity for the smart watch based on the device identification information sent by the smart watch.
[0156] In some embodiments, the device registration thread can add the device identification information to the above registration information and then send it to the server. Exemplarily, the registration information is regastID, and the device identification information is PIN; after receiving the registration information, the device registration thread can add the device identification information to the registration information. For example, regastID(PIN), and then the device registration thread sends the registration information with the device identification information to the cloud server.
[0157] In some embodiments, the device registration thread may also concatenate the device identification information with the registration information and send it to the server. Exemplarily, the registration information is regastID, and the device identification information is PIN; after receiving the registration information, the device registration thread may concatenate the device identification information with the device identification information, such as regastID+PIN, and then the device registration thread sends the concatenated device identification information and registration information to the cloud server.
[0158] S102a6. In response to verifying that the device identification information meets the preset requirements, the cloud server 403 sends a registration pass mark to the smart watch.
[0159] Among them, the cloud server verifies that the device identification information meets the preset, which can be understood as the device identification information sent by the smart watch is valid. In some embodiments, verifying that the device identification information meets the preset can also be expressed as verifying that the device identification information passes. Exemplarily, the cloud server can determine whether the device identification information sent by the smart watch meets the preset by comparing the device identification information in the database with the device identification information sent by the smart watch. Alternatively, the cloud server can also use some verification algorithms to verify whether the device identification information sent by the smart watch meets the preset. The embodiments of the present application are not limited to this.
[0160] Exemplarily, the device registration thread of the smart watch may receive the registration pass identifier sent by the cloud server.
[0161] For example, see again Fig. 9 ,The communication between the device registration thread and the cloud server 403 can be carried out via the HTTP protocol.
[0162] It is understandable that in some scenarios, for IoT devices, especially for IoT devices that do not have the ability to independently register devices, the above steps S102a3 and S102a4 can also be performed by the mobile phone instead of the device registration thread. That is to say, the mobile phone sends account information to the cloud server 403, and then the cloud server 403 sends registration information to the mobile phone. After that, the mobile phone sends the registration information to the smart watch. Then, the smart watch executes step S102a5 to send device identification information and registration information to the server 403. To complete the device registration of the smart watch. It can be seen that this registration process has good versatility and can be used for electronic devices with independent registration capabilities and electronic devices without independent registration capabilities.
[0163] In other embodiments, if the communication quality between the smart watch and the server is not high and there is some delay, the above steps S102a3 and S102a4 can also be performed by a mobile phone that has established a communication connection (such as a Bluetooth connection) with the smart watch. In this way, by reducing the communication process between the smart watch and the server, the slow registration caused by the low communication quality between the smart watch and the server can be alleviated; the registration efficiency of the smart watch can be improved, and the user experience can be improved.
[0164] It can be understood that in some embodiments, the above steps S102a4 and S102a5 are optional. The above step S102a3 can also be that the device registration thread sends the account information and device identification information to the cloud server 403. The above step S102a6 can be that in response to the verification of the account information and the device identification information passing, a registration pass mark is sent to the device registration thread. In this way, the registration process of the smart watch can be simplified and the registration time of the smart watch can be saved.
[0165] S103. In response to the device registration thread being successfully registered, the smart watch destroys the device registration thread.
[0166] In some embodiments, the above step S103 may be that, in response to receiving the registration success flag, the device registration thread destroys itself.
[0167] In some embodiments, the above step S103 may also be that, in response to receiving the registration pass mark, the registration query unit instructs the device registration thread to be destroyed. In other embodiments, the above step S103 may also be that, in response to the registration query unit detecting the registration pass mark, the registration query unit instructs the device registration thread to self-destruct, etc. The embodiment of the present application does not impose any restrictions on the way in which the smart watch destroys the device registration thread.
[0168] S104. The smart watch starts a message processing thread and a message sending and receiving thread.
[0169] It is understandable that when the smartwatch destroys the device registration thread, the message processing thread and the message receiving and sending thread are started again. In this way, the device registration thread on the smartwatch will not exist at the same time as the message receiving and sending thread and the message processing thread. The number of threads existing simultaneously on the smartwatch can be reduced, and the occupation of smartwatch resources can be reduced, thereby alleviating the resource shortage on the smartwatch. In addition, the phenomenon of freezing and slow operation on the smartwatch can be reduced, which can improve the user experience.
[0170] In some embodiments, see again Fig.10 Step S104 may include: S104a1 and S104a2.
[0171] S104a1. The registration query unit starts a message processing thread.
[0172] S104a2. The registration query unit starts a message sending and receiving thread.
[0173] It can be understood that by starting the message processing thread first and then starting the message sending and receiving thread, the smart watch can process the message sent by the cloud server 403 in a timely manner to execute the function indicated by the message.
[0174] It is understandable that the smartwatch may start the message receiving and sending thread first and then the message processing thread; in this way, the situation where the message sent by the cloud server 403 cannot be received due to the message receiving and sending thread not being started can be reduced. Also, in some embodiments, the message processing thread and the message receiving and sending thread may be started at the same time.
[0175] In some embodiments, after step S104, the thread management method provided by the embodiments of the present application may further include step S105.
[0176] S105. The smart watch receives the message sent by the server and executes the function indicated by the message.
[0177] In some embodiments, see Fig.14 , the above step S105 may include: S105a1-S105a5.
[0178] S105a1. The mobile phone sends a message to the cloud server 403.
[0179] In some embodiments, the above message can be a control instruction of a mobile phone reminder APP (such as controlling a smart watch to give a reminder when a countdown ends, controlling a smart watch to give a reminder when a schedule time is reached, etc.) It can also be a notification message of some instant communication APP (such as pictures, texts, voices, etc. sent to the user by a user's social friends). It can also be a notification message sent by a smart space APP (such as a smart kettle has finished boiling water, etc.). The embodiments of the present application do not impose any restrictions on this.
[0180] For example, see Fig.11 The scenario shown. The reminder APP (such as countdown, schedule planning, etc.) in the mobile phone 402 can send a control message to the smart watch at a preset time (for example, the countdown ends, the schedule planning reaches the preset time), so that the smart watch 401 vibrates to remind the user 400. Since the user 400 has moved outdoors, the near field connection with the mobile phone 402 is disconnected. At this time, the mobile phone 402 will send a control message to the cloud server 403. Afterwards, the cloud server 403 forwards the control message to the smart watch.
[0181] Again, for example, see Fig.11 The scenario shown. Mobile phone 402 sends a picture message to cloud server 403. Afterwards, cloud server 403 can forward the picture message to smart watch 401. The message sending and receiving thread of smart watch 401 receives the picture message. Next, the message sending and receiving thread forwards the picture message to the message processing thread. Afterwards, the message processing thread saves the picture message to the memory of smart watch 401, or displays the picture carried in the picture message.
[0182] S105a2. The cloud server sends the message to the smart watch.
[0183] After receiving the message, the cloud server 403 can send the message to the smart watch.
[0184] S105a3. The message receiving and sending thread of the smart watch receives the message and sends the received message to the message processing thread.
[0185] Exemplarily, the communication between the information sending and receiving thread and the cloud server can be performed through the MQTT protocol.
[0186] S105a4. The message processing thread of the smart watch parses the message and sends the parsed message to the watch business module.
[0187] Exemplarily, the message processing module may parse the message by decoding or decrypting, and send the parsed message to the watch service module.
[0188] S105a5. The watch service module executes the function indicated by the message based on the parsed message.
[0189] For example, based on the parsed message, the mobile phone service module can control the watch to vibrate to remind the user that the countdown has ended; or, it can control the watch to emit a reminder sound through the speaker to remind the user that the schedule has reached the preset time.
[0190] It is understandable that after the smart watch is registered, there may be other ways to receive the message sent by the cloud server 403 and execute the preset function based on the message. Relevant technicians can design this according to actual usage needs, and the embodiment of the present application does not impose any limitation on this.
[0191] Next, we will Figure 1 In the communication system shown, the terminal device 100 is a mobile phone, the electronic device 200 is a smart switch that does not have independent registration capability, and the server 300 is a cloud server, for example, to illustrate the thread management method provided in the embodiment of the present application.
[0192] See also Fig.15The thread management method provided in the embodiment of the present application may include steps S201-S202.
[0193] In some embodiments, the thread management method provided by the embodiments of the present application may further include: step S200.
[0194] S200. The intelligent switch performs remote communication initialization.
[0195] This step is similar to the above step S100, and reference may be made to the above related description, which will not be repeated here.
[0196] It can be understood that, in some embodiments, for some electronic devices, the remote communication capabilities of these electronic devices may be provided by the system modules of the electronic devices. Therefore, for these electronic devices, step S200 may not be executed, and they may still have the remote communication capabilities.
[0197] S201. In response to the intelligent switch receiving the start instruction, the intelligent switch starts a message processing thread and a message sending and receiving thread.
[0198] The above-mentioned start-up instruction may be that the smart switch is turned on, the smart switch establishes a Bluetooth connection with the mobile phone, or the user binds the user account with the smart switch on the mobile phone, etc. The embodiment of the present application does not impose any limitation on this.
[0199] For example, the user can use the Smart Space APP on the mobile phone to establish a Bluetooth connection with the smart switch. This step is similar to the step of establishing a Bluetooth connection between the mobile phone and the smart watch. Figure 5 And the corresponding description. I will not repeat it here. After that, the smart switch detects that a Bluetooth connection is established with the mobile phone; in this way, the smart switch can receive messages sent by the mobile phone through the Bluetooth module and execute the function of turning on or off the line connected to the smart switch. After that, the smart switch can start the message processing thread and the message sending and receiving thread.
[0200] In some of the above embodiments, the smart switch can first start the message sending and receiving thread, and then start the message processing thread, so that the smart switch can receive the registration information sent by the mobile phone in a timely manner, alleviating the situation where the registration information sent by the mobile phone cannot be received because the message sending and receiving thread is not started.
[0201] S202. In response to the smart switch receiving the registration instruction, the smart switch registers with the cloud server through a message sending and receiving thread and a message processing thread.
[0202] In some embodiments, the message receiving and sending thread of the smart switch can obtain registration information. For example, the message receiving and sending thread can obtain registration information from a server, or obtain registration information from a terminal device. And, the message processing thread obtains the device identification of the electronic device. For example, the message processing thread searches for the device identification from the memory of the smart switch. Afterwards, the message processing thread sends the device identification to the message receiving and sending thread. Next, the message processing thread sends the device identification to the message receiving and sending thread of the smart switch, so that the server sends a registration pass identification to the electronic device when the registration information and the device identification are verified. Then, the message receiving and sending thread receives the registration pass identification sent by the server.
[0203] In some embodiments, the message sending and receiving thread of the smart switch can receive the account information sent by the mobile phone. Afterwards, the message sending and receiving thread forwards the received account information to the message processing thread. Next, the message processing thread sends the account information and the device identification of the smart switch to the message sending and receiving thread. Among them, the device identification of the smart switch can be obtained by the smart switch from its memory. Then, the message processing thread sends the account information and the device identification to the server, so that the server sends a registration pass identification to the message sending and receiving thread of the smart switch when verifying that the account information is passed. In this way, the smart switch can dynamically merge the device registration thread into the message processing thread and the message sending and receiving thread.
[0204] It is understandable that the smart switch can assign the device registration function performed by the device registration thread to the message sending and receiving thread and the message processing thread. In other words, the device registration thread can be dynamically integrated with the message processing thread and the message sending and receiving thread. In this way, the number of threads on the smart switch will be reduced, and the device registration thread will not be started on the smart switch. It can be seen that the smart switch can register the smart switch by dynamically integrating device registration with message processing and message sending and receiving. Therefore, when the smart switch registers the device, the message sending and receiving thread and the message processing thread will be started on the smart switch; the device registration thread will not be started on the smart switch. It can save the resources of the smart switch and reduce the occupation of resources on the smart switch. It can reduce the phenomenon of freezes and slow operation on the smart switch, and can improve the user experience.
[0205] After the smart switch establishes a Bluetooth connection with the mobile phone, the smart switch may not have been registered with the cloud server, or the registration may have expired. Based on this, the smart switch can complete the registration with the cloud server with the assistance of the mobile phone, so that after registration, the smart switch can use the remote communication function.
[0206] The registration instruction may be registration information sent by the mobile phone to the smart switch, or a preset field that instructs the smart switch to start device registration, or a button on the smart switch triggered by the user that instructs the smart switch to enable remote capabilities, or a communication connection established between the smart switch and the mobile phone, etc.
[0207] Exemplarily, in response to the user triggering the remote mode on button on the smart switch, the smart module registers with the server through the message sending and receiving thread and the message processing thread. At this time, the smart switch does not start the device registration thread. Afterwards, the smart switch registers with the cloud server with the assistance of the mobile phone.
[0208] For example, see Fig.16 The above step S202 may include: steps S202a1-S202a7.
[0209] S202a1. The mobile phone sends account information to the cloud server 403.
[0210] In some embodiments, the account information can be sent to the cloud server by a device management app on the mobile phone (such as the Smart Space app).
[0211] For example, see Fig.17 In response to the user clicking on the smart switch option 1802 in the device management interface 1800 , a device management menu pops up in the device management interface 1800 . In response to the user clicking on the “Login Account” option 1803 in the device management menu, the mobile phone sends the user account to the cloud server 403 .
[0212] The rest of the implementation process of step S202a1 is similar to the above steps S102a2 and S102a3, and reference may be made to the above related descriptions, which will not be repeated here.
[0213] S202a2. In response to verifying that the account information meets the preset requirements, the cloud server 403 sends registration information to the mobile phone.
[0214] S202a3. The mobile phone sends the registration information to the smart switch.
[0215] Exemplarily, the registration information sent by the mobile phone can be received by the message sending and receiving thread of the smart switch.
[0216] Step S202a2 and step S202a3 are similar to the above-mentioned step S102a4, and reference may be made to the above-mentioned related descriptions, which will not be repeated here.
[0217] S202a4. The message sending and receiving thread forwards the registration information to the message processing thread.
[0218] S202a5. In response to receiving the registration information, the message processing thread sends the device identification information to the message sending and receiving thread.
[0219] S202a6. The message sending and receiving thread sends the above device identification and registration information to the cloud server 403.
[0220] Exemplarily, the communication between the message sending and receiving thread and the cloud server can adopt the HTTP protocol. The embodiment of the present application does not impose any restrictions on the communication protocol between the message receiving thread and the cloud server.
[0221] S202a7. In response to the verification of the device identification being successful, the cloud server sends a registration success identification to the message sending and receiving thread.
[0222] This step is similar to the above step S102a6 and will not be described again here.
[0223] In this way, the smart switch can complete registration on the cloud server 403, and then the user can use the remote function of the smart switch, for example, remotely control the smart switch to turn on or off the line connected to the smart switch, etc.
[0224] It should be noted that, for some electronic devices with independent registration capabilities, thread management can also be performed through the above steps S201 and S202. The implementation method thereof can be found in the above description, and this embodiment of the present application will not be elaborated on.
[0225] It is understandable that in order to achieve the above functions, the thread management device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware 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 in combination with the embodiments, but such implementation should not be considered to be beyond the scope of this application.
[0226] This embodiment can divide the thread management device into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0227] The embodiment of the present application also provides a thread management device, which may be the above-mentioned electronic device or terminal device, such as Fig.18As shown, the thread management device may include one or more processors 1901 , a memory 1902 , and a communication interface 1903 .
[0228] The memory 1902 and the communication interface 1903 are coupled to the processor 1901. For example, the memory 1902, the communication interface 1903 and the processor 1901 may be coupled together via a bus 1904.
[0229] The communication interface 1903 is used for data transmission with other devices. The memory 1902 stores computer program codes. The computer program codes include computer instructions. When the computer instructions are executed by the processor 1901, the electronic device performs the device authentication in the embodiment of the present application.
[0230] Among them, the processor 1901 can be a processor or a controller, for example, a central processing unit (CPU), a general processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the present disclosure. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0231] The bus 1904 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus 1904 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.18 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0232] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program code is stored. When the processor executes the computer program code, the electronic device executes the relevant method steps in the method embodiment.
[0233] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the relevant method steps in the above method embodiment.
[0234] Among them, the electronic device, computer-readable storage medium or computer program product provided in this application is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0235] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0236] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0237] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0238] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0239] If the integrated 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 readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0240] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A thread management method, characterized in that: Applied to an electronic device, the electronic device includes a device registration thread, a message sending and receiving thread, and a message processing thread; the method includes: In response to detecting that the electronic device is not registered, starting the device registration thread, and the message sending and receiving thread and the message processing thread are in an unstarted state; The device is registered with the server through the device registration thread.
2. The method according to claim 1, characterized in that The method further comprises: In response to the device registration performed by the device registration thread being successful, destroying the device registration thread; The message sending and receiving thread and the message processing thread are started.
3. The method according to claim 1 or 2, characterized in that: In response to detecting that the electronic device is not registered, starting the device registration thread includes: In response to detecting that the electronic device is not registered, if the message processing thread and the message sending and receiving thread are in the started state, the device registration thread is started after the message processing thread and the message sending and receiving thread are destroyed.
4. The method according to any one of claims 1 to 3, characterized in that: In response to detecting that the electronic device is not registered, starting the device registration thread includes: In response to detecting that the electronic device is not registered when the electronic device is in the remote communication mode, the device registration thread is started.
5. The method according to any one of claims 1 to 4, characterized in that: The registering the device with the server through the device registration thread includes: Get account information; The device registration thread sends the account information to the server, so that the server sends registration information to the electronic device when the account information is verified; The device registration thread receives the registration information sent by the server; The device registration thread sends the device identification of the electronic device to the server, so that the server sends a registration pass identification to the electronic device when the device identification is verified; The device registration thread receives the registration success identifier sent by the server.
6. The method according to claim 5, characterized in that The obtaining of account information includes: Obtaining account information entered by a user on the electronic device; Alternatively, receive account information sent by the terminal device.
7. The method according to any one of claims 1 to 6, characterized in that: The registering the device with the server through the device registration thread includes: The device registration thread sends the device identification and registration information of the electronic device to the server, so that the server sends a registration pass identifier to the electronic device when the device identification and the registration information are verified; the registration information comes from the terminal device and is obtained by the terminal device from the server; The device registration thread receives the registration success identifier sent by the server.
8. The method according to any one of claims 1 to 7, characterized in that: The detecting that the electronic device is not registered includes: Search registration by logo; If the registration pass identifier cannot be found, it is determined that the electronic device is not registered.
9. A thread management method, characterized in that: Applied to an electronic device, the electronic device includes a message sending and receiving thread and a message processing thread; the method includes: Starting the message sending and receiving thread and the message processing thread; The message sending and receiving thread receives registration information, and the message processing thread obtains the device identification of the electronic device; The message processing thread sends the device identification to the message sending and receiving thread; The message processing thread sends the registration information and the device identification to the server, so that the server sends a registration pass identification to the electronic device when verifying that the registration information and the device identification are passed; The message sending and receiving thread receives the registration success identifier sent by the server.
10. The method according to claim 9, characterized in that The message sending and receiving thread receives registration information, including: The message sending and receiving thread receives the registration information from the terminal device, where the registration information is obtained by the terminal device from the server; or, The messaging thread receives the registration information from the server.
11. The method according to claim 9 or 10, characterized in that: The starting of the message sending and receiving thread and the message processing thread includes: The message sending and receiving thread is started first, and then the message processing thread is started.
12. An electronic device, characterized in that: The electronic device includes a memory and one or more processors, wherein the memory is coupled to the processor; wherein the memory stores computer program code, and the computer program code includes computer instructions; when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1 to 8, or executes the method as described in any one of claims 9 to 11.
13. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, enable the electronic device to execute a method as claimed in any one of claims 1 to 8, or to execute a method as claimed in any one of claims 9 to 11.
