CN110580188B - Multithreading network allocation method and storage medium - Google Patents

Multithreading network allocation method and storage medium Download PDF

Info

Publication number
CN110580188B
CN110580188B CN201910837569.6A CN201910837569A CN110580188B CN 110580188 B CN110580188 B CN 110580188B CN 201910837569 A CN201910837569 A CN 201910837569A CN 110580188 B CN110580188 B CN 110580188B
Authority
CN
China
Prior art keywords
network
sub
network allocation
thread
task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910837569.6A
Other languages
Chinese (zh)
Other versions
CN110580188A (en
Inventor
周广生
许金秧
陆愿基
邱园
张军
冉东军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Gree Electric Appliances Inc of Zhuhai
Zhuhai Lianyun Technology Co Ltd
Original Assignee
Gree Electric Appliances Inc of Zhuhai
Zhuhai Lianyun Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Gree Electric Appliances Inc of Zhuhai, Zhuhai Lianyun Technology Co Ltd filed Critical Gree Electric Appliances Inc of Zhuhai
Priority to CN201910837569.6A priority Critical patent/CN110580188B/en
Publication of CN110580188A publication Critical patent/CN110580188A/en
Application granted granted Critical
Publication of CN110580188B publication Critical patent/CN110580188B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application discloses a multithreading network distribution method and a storage medium, wherein when a main thread operated by a terminal device receives a plurality of network distribution tasks sent by a user and aiming at a plurality of electronic devices, the main thread establishes a plurality of sub-threads, so that the sub-threads respectively execute the corresponding network distribution tasks at the same time, and the network distribution results obtained by respectively executing the corresponding network distribution tasks are sent to the main thread, thereby solving the problem that the terminal device can only distribute a network to one electronic device at the same time, realizing that the terminal device can distribute a network to a plurality of electronic devices at the same time, improving the network distribution efficiency and improving the user experience.

Description

Multithreading network allocation method and storage medium
Technical Field
The application relates to the technical field of distribution networks, in particular to a multithreading distribution network method and a storage medium.
Background
The existing distribution network technology integrates various electronic devices by using a computer technology, a microelectronic technology and a communication technology, so that basic use requirements can be provided for users, the network technology can be utilized to enable the users to enjoy personalized functions of the electronic devices, and convenience, comfort and user experience of the users in using the electronic devices are improved. The distribution network technology is currently in a high-speed development period, as more and more electronic devices are owned by each person on average, when terminal equipment distributes network to each electronic device of a user, the terminal equipment can only distribute network to one electronic device at the same time, so that the problem of low distribution network efficiency exists in the terminal equipment. Based on this, providing a method capable of distributing a network to a plurality of electronic devices at the same time is a technical problem to be solved.
Disclosure of Invention
The application provides a multithreading network distribution method and a storage medium, which can distribute networks to a plurality of electronic devices at the same time, and effectively improve the network distribution efficiency of the electronic devices.
In order to achieve the above purpose, the embodiment of the present application adopts the following technical scheme:
a multi-threaded networking method comprising:
when the main thread receives the network allocation task, counting the number of all the sub-threads capable of executing the network allocation task, judging whether the number reaches a preset threshold value or not and judging whether idle sub-threads exist or not;
if the number does not reach the preset threshold value and no idle sub-threads exist, the main thread establishes sub-threads corresponding to the network allocation task received by the main thread, and sends the network allocation task to the established sub-threads;
each newly-built sub-thread respectively executes a corresponding distribution network task to obtain a distribution network result, and the distribution network result is sent to the main thread.
In a preferred option of the embodiment of the present application, in the above multithreading network allocation method, when the main thread receives the network allocation task, counting the number of all the sub-threads capable of executing the network allocation task, and after the steps of judging whether the number reaches a preset threshold and judging whether there are idle sub-threads, the method further includes:
if the number reaches a preset threshold value for the first time, the main thread creates a to-be-executed distribution network task list, and stores the distribution network task to the to-be-executed distribution network task list;
when the main thread detects that the sub thread is idle, the sub thread sends the network allocation task to be executed in the network allocation task list to the sub thread, so that the sub thread executes the network allocation task to obtain a network allocation result, and the network allocation result is sent to the main thread.
In a preferred option of the embodiment of the present application, in the above-mentioned multithreading network allocation method, the method includes:
the main thread distributes serial numbers for the distribution network tasks according to the sequence of the received distribution network tasks, wherein the serial number corresponding to the previously received distribution network task is smaller than the serial number corresponding to the later received distribution network task, and the distribution network tasks are stored in a to-be-executed distribution network task list created by the main thread according to the sequence of the corresponding serial numbers from small to large;
when the main thread detects that the sub thread is idle, the sub thread sends the network allocation task with the minimum serial number in the network allocation task list to be executed to the sub thread, so that the sub thread executes the network allocation task to obtain a network allocation result, the network allocation result is sent to the main thread, and the network allocation task is deleted from the network allocation task list to be executed.
In a preferred option of the embodiment of the present application, in the above multithreading network allocation method, when the main thread receives the network allocation task, counting the number of all the sub-threads capable of executing the network allocation task, and after the steps of judging whether the number reaches a preset threshold and judging whether there are idle sub-threads, the method further includes:
if the number of the sub-threads does not reach the preset threshold and idle sub-threads exist, the main thread sends the network allocation task to the idle sub-threads, so that the sub-threads execute the network allocation task to obtain a network allocation result and send the network allocation result to the main thread.
In a preferred option of the embodiment of the present application, in the above-mentioned multithreading network allocation method, the method further includes:
and the main thread monitors the distribution network progress of the sub thread when executing the corresponding distribution network task, and generates a distribution network interface based on the distribution network progress and displays the distribution network interface.
In a preferred option of the embodiment of the present application, in the above-mentioned multithreading network allocation method, when the sub-threads execute corresponding network allocation tasks, the method further includes:
and the main thread receives other tasks sent by the user and executes the other tasks.
In a preferred option of the embodiment of the present application, in the above-mentioned multithreading network allocation method, the method further includes:
when the main thread receives a network allocation canceling command which is sent by a user and aims at a target network allocation task, the main thread sends the network allocation canceling command to a sub-thread corresponding to the target network allocation task, so that the sub-thread stops the network allocation according to the received network allocation canceling command.
In a preferred option of the embodiment of the present application, in the above-mentioned multithreading network allocation method, the method further includes:
the sub-thread starts timing when starting to execute the corresponding network allocation task, stops the network allocation when the timing reaches a preset time threshold and the network allocation is not completed yet, generates a network allocation result, and sends the network allocation result to the main thread, wherein the network allocation result is a network allocation failure;
and when the main thread receives the network distribution result, generating a network distribution result display interface based on the network distribution result and displaying the network distribution result display interface.
In a preferred option of the embodiment of the present application, in the above-mentioned multithreading network allocation method, after the step of executing the sub-thread to execute the corresponding network allocation task to obtain the network allocation result and sending the network allocation result to the main thread, the method further includes:
and the main thread starts timing when detecting that each sub-thread is in an idle state, and recovers the sub-thread when the timing reaches a preset waiting time threshold and the network allocation task sent by the user is not received yet.
The application also provides a storage medium storing a computer program executable by one or more processors for implementing the multi-threaded networking method of any one of the above.
The application provides a multithreading network distribution method and a storage medium, wherein when a main thread operated by a terminal device receives a plurality of network distribution tasks sent by a user and aiming at a plurality of electronic devices, the main thread establishes a plurality of sub-threads, so that the sub-threads respectively execute the corresponding network distribution tasks at the same time, and the network distribution results obtained by respectively executing the corresponding network distribution tasks are sent to the main thread, thereby solving the problem that the terminal device can only distribute a network to one electronic device at the same time, realizing that the terminal device can distribute a network to a plurality of electronic devices at the same time, improving the network distribution efficiency and improving the user experience.
Drawings
The scope of the present disclosure will be better understood from the following detailed description of exemplary embodiments, read in conjunction with the accompanying drawings. The drawings included herein are:
FIG. 1 is a flowchart of a method for multithreading network allocation according to an embodiment of the present application;
FIG. 2 is a flowchart of a sub-thread distribution timeout process in a multi-thread distribution method according to an embodiment of the present application;
fig. 3 is a flowchart of a network allocation task in a to-be-executed network allocation task list in the multithreading network allocation method according to the embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments of the present application.
Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
Referring to fig. 1, an embodiment of the present application provides a multi-thread network allocation method, which includes steps S110 to S130.
Step S110, when the main thread receives the network allocation task, counting the number of all the sub-threads capable of executing the network allocation task, judging whether the number reaches a preset threshold value or not, and judging whether idle sub-threads exist or not.
Specifically, the main thread may be used to perform operations such as generating multiple sub-threads and managing the multiple sub-threads generated by the main thread; the main thread receives the network allocation task sent by the terminal equipment based on the operation of the user, wherein the network allocation task comprises equipment information of electronic equipment to be allocated with a network, which is obtained by the terminal equipment based on the operation of the user, and the electronic equipment to be allocated with the network comprises but is not limited to: air conditioner, fan, air purifier, humidifier, electric cooker, refrigerator, water purifier, water heater and intelligent door lock; the method for obtaining the equipment information of the electronic equipment to be distributed based on the operation of the user by the terminal equipment comprises the following steps: the terminal equipment obtains equipment information of the electronic equipment to be distributed on the basis of the input equipment such as the scanning software, the scanning instrument, the keyboard, the recorder and the like which are operated by a user; the device information includes, but is not limited to, the type of the electronic device of the network to be distributed and the model of the electronic device of the network to be distributed.
It will be appreciated that the number of sub-threads that the main thread can create should be less than or equal to the preset threshold, i.e. when the number of sub-threads that the main thread has created reaches the preset threshold, the main thread will not be able to continue to create sub-threads.
The preset threshold may be 2 to 10, and preferably, in this embodiment, the preset threshold is 3.
In addition, because the corresponding distribution network tasks executed by each sub-thread are different, the progress of executing the distribution network tasks by each sub-thread is also different, when the main thread receives the new distribution network tasks, the main thread is used for judging whether idle sub-threads exist or not, so that when the current distribution network tasks are completed by the execution of the sub-threads and are in an idle state, the new distribution network tasks are allocated to the sub-threads, and the main thread is not required to be allocated with new sub-threads again, so that the waste of sub-thread resources is avoided.
Step S120, if the number does not reach the preset threshold and there is no idle sub-thread, the main thread creates a sub-thread corresponding to the network allocation task received by the main thread, and sends the network allocation task to the created sub-thread.
Specifically, if the number of the sub-threads created by the main thread does not reach the preset threshold and there is no idle sub-thread, it means that the main thread can still continue to create a new sub-thread, and no sub-thread capable of executing the newly received network allocation task is found in the previously created sub-threads, so that the main thread creates a new sub-thread corresponding to the newly received network allocation task and sends the network allocation task to the sub-thread.
Step S130, each newly-built sub-thread executes a corresponding network allocation task to obtain a network allocation result, and sends the network allocation result to the main thread.
Specifically, the step of executing the corresponding distribution network task by each newly-built sub-thread includes: the sub-thread analyzes the equipment information of the corresponding electronic equipment to be distributed from the corresponding distribution network task, searches the MAC address of the electronic equipment to be distributed from the equipment information, and completes distribution network when uploading the MAC address to a server specified by a manufacturer of the electronic equipment to be distributed, and generates a distribution network result of successful distribution network; it can be appreciated that when the MAC address is not uploaded to the server or parsed from the distribution task to the MAC address, the distribution result is a distribution failure.
In this embodiment, after performing step S130, the method further includes: and the main thread monitors the distribution network progress of the sub thread when executing the corresponding distribution network task, and generates a distribution network interface based on the distribution network progress and displays the distribution network interface.
Specifically, the distribution network interface includes a distribution network progress list, where the distribution network progress list is used to record the progress of the execution of the distribution network task by the sub-thread, and the distribution network progress list further includes device information of electronic devices corresponding to each distribution network task, so that a user can check the device information of the target electronic device corresponding to the target distribution network task by clicking the progress of the target distribution network task in the distribution network progress list.
In this embodiment, the corresponding network allocation tasks received by the plurality of sub-threads are independent of each other, and the network allocation steps of the sub-threads do not affect each other.
In order to further improve the utilization rate of the main thread, in this embodiment, the main thread receives other tasks sent by the user and executes the other tasks.
It may be appreciated that, when the sub-thread executes the network allocation task, the user may send an interface shrink or hide command to the main thread to cause the main thread to shrink or hide the network allocation interface to a corner of the terminal device screen, and cause the sub-thread to continue executing the network allocation task in the background, while the user may send other tasks to the main thread to cause the main thread to receive other tasks sent by the user and execute the other tasks, where the other tasks include, but are not limited to: browsing the first page information of the application program corresponding to the main thread, checking the user setting information in the application program corresponding to the main thread, purchasing goods on line through the application program corresponding to the main thread, and reserving the maintenance time of the electronic equipment through the application program corresponding to the main thread.
It can be understood that, the user may also send an interface recovery command to the main thread by clicking the network allocation interface shrunk to a corner of the screen of the terminal device, so that the main thread recovers the network allocation interface to a normal size, so that the user can check the progress of executing the network allocation task by the sub-thread.
It can be understood that when the network allocation result obtained by executing the corresponding network allocation task by the sub-thread is that the network allocation is successful, the sub-thread sends the network allocation result that the network allocation is successful to the main thread, the main thread sends a prompt for performing subsequent operations to the user, and the user executes the subsequent operations according to the prompt for the subsequent operations, where the subsequent operations include selecting an application scenario of the electronic device that the network allocation is successful.
In this embodiment, when the main thread receives a network allocation cancellation command sent by a user and directed to a target network allocation task, the main thread sends the network allocation cancellation command to a sub-thread corresponding to the target network allocation task, so that the sub-thread stops executing the corresponding network allocation task according to the received network allocation cancellation command.
It may be appreciated that the manner in which the user sends the cancel distribution command for the target distribution task may be by clicking on the target distribution task in the distribution progress list and selecting to cancel the target distribution task. Referring to fig. 2, in this embodiment, when the child thread is executing the network allocation task and if a timeout occurs, steps S210 to S240 are executed.
Step S210: and the sub-thread starts timing when starting to execute the corresponding distribution network task.
Step S220: and stopping the network distribution when the timing reaches a preset time threshold and the network distribution is not completed yet.
Specifically, the preset time threshold may be 60 seconds to 180 seconds, and preferably, the preset time threshold in this embodiment is 120 seconds.
Step S230: the sub-thread generates a distribution network result and sends the distribution network result to the main thread.
It can be understood that when the timing reaches the preset time threshold and the distribution network is not completed yet, the sub-thread indicates that the execution of the distribution network task is overtime, that is, the distribution network result is that the distribution network fails.
Step S240: and when the main thread receives the network distribution result, generating a network distribution result display interface based on the network distribution result and displaying the network distribution result display interface.
When the main thread receives the distribution network result, a distribution network result display interface is generated and displayed based on the distribution network result, a retry distribution network prompt message is generated, if the main thread receives a retry distribution network command sent by a user based on the retry distribution network prompt message, the main thread analyzes the retry distribution network command into a new distribution network task, and the steps S110 to S130 are executed in a return mode; if the main thread receives a network allocation canceling and retrying command sent by a user, the working state of the sub thread is changed into an idle state to wait for the main thread to reclaim or execute a new network allocation task sent by the main thread, wherein the sub thread is a sub thread for sending a network allocation result of network allocation failure to the main thread.
In this embodiment, the main thread starts timing when detecting that each sub-thread is in an idle state, and recovers the sub-thread when the timing reaches a preset waiting time threshold and the network allocation task sent by the user is not received yet.
Optionally, the preset waiting time threshold is 60 seconds to 180 seconds, and preferably, the preset waiting time threshold in this embodiment is 120 seconds.
In this embodiment, after performing step S110, the method further includes:
if the number of all the sub-threads capable of executing the network allocation task reaches a preset threshold value for the first time, the main thread creates a network allocation task list to be executed, and stores the network allocation task to the network allocation task list to be executed; when the main thread detects that the sub thread is idle, the sub thread sends the network allocation task to be executed in the network allocation task list to the sub thread, so that the sub thread executes the network allocation task to obtain a network allocation result, and the network allocation result is sent to the main thread.
It can be understood that when the number of all the sub-threads capable of executing the network allocation task reaches the preset threshold, it indicates that the main thread cannot create new sub-threads any more, so that the main thread creates a network allocation task list to be executed, and stores the received network allocation task to the network allocation task list to be executed, where the network allocation task waits to be executed. It is understood that the distribution network policies implemented for the distribution network tasks stored in the to-be-executed distribution network task list include, but are not limited to: the network allocation strategy of first receiving and first executing, executing according to random sequence, first receiving and then executing, and in general case, the network allocation strategy of first receiving and first executing accords with the subjective intention of the user, so in this embodiment, the network allocation strategy of first receiving and first executing is implemented on the network allocation task received by the main thread, that is, the priority of the network allocation task with small serial number in the network allocation task list to be executed is higher than the priority of the network allocation task with large serial number, and the network allocation task with small serial number is executed before the network allocation task with large serial number.
Optionally, referring to fig. 3 in the present embodiment, if the number of all the sub-threads capable of executing the network allocation task reaches the preset threshold for the first time, steps S310 to S340 are executed.
Step S310: and the main thread distributes serial numbers for the distribution network tasks according to the sequence of the received distribution network tasks.
The sequence number corresponding to the network allocation task received in advance is smaller than the sequence number corresponding to the network allocation task received in later.
Step S320: and the main thread stores the distribution network task to a to-be-executed distribution network task list created by the main thread according to the sequence from small to large of the corresponding sequence number.
Step S330: when the main thread detects that the sub thread is idle, the network allocation task with the minimum serial number in the network allocation task list to be executed is sent to the sub thread, so that the sub thread executes the network allocation task to obtain a network allocation result, and the network allocation result is sent to the main thread.
Step S340: and deleting the distribution network task from the to-be-executed distribution network task list by the main thread.
It will be appreciated that after the network allocation task is sent to the sub-thread, the main thread should delete the network allocation task from the network allocation task list to be executed, so that the network allocation task with the serial number greater than and closest to the serial number of the network allocation task in the network allocation task list to be executed becomes the network allocation task with the minimum serial number, and send the network allocation task with the minimum serial number to the sub-thread when the main thread detects that the sub-thread is idle again.
It can be understood that if the number of all the sub-threads capable of executing the network allocation task reaches the preset threshold again, the main thread allocates a current maximum serial number for the network allocation task received again, stores the current maximum serial number in the created network allocation task list to be executed, and waits for the sub-thread designated by the main thread to execute according to the principle of first receiving and first executing in the embodiment.
It can be understood that when the number of all the sub-threads capable of executing the network allocation task reaches the preset threshold and there are idle sub-threads, it indicates that the main thread cannot create a new sub-thread again, but there are idle sub-threads in the existing sub-threads, so that the main thread receives the principle of executing first according to the embodiment, assigns a current maximum serial number to the received network allocation task, stores the received network allocation task to the network allocation task list to be executed, and sends the network allocation task with the minimum serial number in the network allocation task list to be executed to the idle sub-threads, so that the sub-thread executes the network allocation task to obtain a network allocation result, sends the network allocation result to the main thread, and deletes the network allocation task from the network allocation task list to be executed.
In this embodiment, after performing step S110, the method further includes: if the number of all the sub-threads capable of executing the network allocation task does not reach a preset threshold and idle sub-threads exist, the main thread sends the network allocation task to the idle sub-threads, so that the sub-threads execute the network allocation task to obtain a network allocation result and send the network allocation result to the main thread.
It can be understood that when the number of all the sub-threads capable of executing the network allocation task does not reach the preset threshold and there is an idle sub-thread, the network allocation task list to be executed of the main thread is indicated to be empty, and the idle sub-thread can immediately execute the network allocation task received at the moment, so that the main thread sends the network allocation task to the idle sub-thread; and the sub thread executes the network allocation task to obtain a network allocation result and sends the network allocation result to the main thread.
The embodiment of the application also provides a storage medium, which stores a computer program, can be executed by one or more processors and can be used for realizing the multithreading network allocation method.
In summary, the present application provides a multithreading network allocation method and a storage medium, where when a main thread running in a terminal device receives a plurality of network allocation tasks for a plurality of electronic devices sent by a user, the main thread establishes a plurality of sub-threads, so that the plurality of sub-threads simultaneously execute respective corresponding network allocation tasks, and send network allocation results obtained by respectively executing respective corresponding network allocation tasks to the main thread, thereby solving the problem that the terminal device can only allocate a network to one electronic device at the same time, realizing that the terminal device can allocate networks to a plurality of electronic devices at the same time, improving network allocation efficiency, and improving user experience.
Further, in the process that the plurality of sub-threads execute the plurality of distribution network tasks, the main thread monitors the distribution network progress when the sub-threads execute the corresponding distribution network tasks, generates a distribution network interface based on the distribution network progress and displays the distribution network interface, and a user can check the equipment information of the target electronic equipment corresponding to the target distribution network tasks by clicking the progress of the target distribution network tasks in the distribution network progress list or cancel the distribution network tasks of a certain electronic equipment through the distribution network interface, so that the user can conveniently control the distribution network progress in real time, and the user experience is improved.
Further, in the process that the plurality of sub-threads execute the plurality of network allocation tasks, the main thread can execute other tasks sent by the user when the sub-threads execute the network allocation tasks of the electronic equipment, so that the waste of thread resources is avoided, the waiting time of the user for waiting for the network allocation tasks to be executed is prolonged, and the user experience is greatly improved.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of elements is merely a logical functional division, and there may be additional divisions of actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present application.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several commands for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The above description is only of the preferred embodiments of the present application and is not intended to limit the present application, but various modifications and variations can be made to the present application by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Although the embodiments of the present application are disclosed above, the embodiments are only used for the convenience of understanding the present application, and are not intended to limit the present application. Any person skilled in the art can make any modification and variation in form and detail without departing from the spirit and scope of the present disclosure, but the scope of the present disclosure is still subject to the scope of the present disclosure as defined by the appended claims.

Claims (7)

1. A method for multithreaded networking, the method comprising:
when the main thread receives the network allocation task, counting the number of all the sub-threads capable of executing the network allocation task, judging whether the number reaches a preset threshold value or not and judging whether idle sub-threads exist or not;
if the number does not reach the preset threshold and idle sub-threads exist, the main thread sends the network allocation task to the idle sub-threads, so that the sub-threads execute the network allocation task to obtain a network allocation result and send the network allocation result to the main thread;
if the number does not reach the preset threshold value and no idle sub-threads exist, the main thread establishes sub-threads corresponding to the network allocation task received by the main thread, and sends the network allocation task to the established sub-threads;
each newly-built sub-thread respectively executes a corresponding distribution network task to obtain a distribution network result, and sends the distribution network result to the main thread;
the main thread starts timing when detecting that each sub-thread is in an idle state, and recovers the sub-thread when the timing reaches a preset waiting time threshold and a network allocation task sent by a user is not received yet;
when the sub-thread executes the corresponding distribution network task, the method further comprises:
and the main thread receives other tasks sent by the user and executes the other tasks.
2. The method for multi-thread network allocation according to claim 1, wherein after the steps of counting the number of all the sub-threads capable of executing the network allocation task and judging whether the number reaches a preset threshold and judging whether there are idle sub-threads when the main thread receives the network allocation task, the method further comprises:
if the number reaches a preset threshold value for the first time, the main thread creates a to-be-executed distribution network task list, and stores the distribution network task to the to-be-executed distribution network task list;
when the main thread detects that the sub thread is idle, the sub thread sends the network allocation task to be executed in the network allocation task list to the sub thread, so that the sub thread executes the network allocation task to obtain a network allocation result, and the network allocation result is sent to the main thread.
3. The multi-threaded networking method of claim 2, wherein the method comprises:
the main thread distributes serial numbers for the distribution network tasks according to the sequence of the received distribution network tasks, wherein the serial number corresponding to the previously received distribution network task is smaller than the serial number corresponding to the later received distribution network task, and the distribution network tasks are stored in a to-be-executed distribution network task list created by the main thread according to the sequence of the corresponding serial numbers from small to large;
when the main thread detects that the sub thread is idle, the sub thread sends the network allocation task with the minimum serial number in the network allocation task list to be executed to the sub thread, so that the sub thread executes the network allocation task to obtain a network allocation result, the network allocation result is sent to the main thread, and the network allocation task is deleted from the network allocation task list to be executed.
4. The multithreaded network deployment method of claim 1, wherein the method further comprises:
and the main thread monitors the distribution network progress of the sub thread when executing the corresponding distribution network task, and generates a distribution network interface based on the distribution network progress and displays the distribution network interface.
5. The multithreaded network deployment method of claim 1, wherein the method further comprises:
when the main thread receives a network allocation canceling command which is sent by a user and aims at a target network allocation task, the main thread sends the network allocation canceling command to a sub-thread corresponding to the target network allocation task, so that the sub-thread stops the network allocation according to the received network allocation canceling command.
6. The multithreaded network deployment method of claim 1, wherein the method further comprises:
the sub-thread starts timing when starting to execute the corresponding network allocation task, stops the network allocation when the timing reaches a preset time threshold and the network allocation is not completed yet, generates a network allocation result, and sends the network allocation result to the main thread, wherein the network allocation result is a network allocation failure;
and when the main thread receives the network distribution result, generating a network distribution result display interface based on the network distribution result and displaying the network distribution result display interface.
7. A storage medium storing a computer program executable by one or more processors for implementing a multi-threaded networking method as claimed in any one of claims 1 to 6.
CN201910837569.6A 2019-09-05 2019-09-05 Multithreading network allocation method and storage medium Active CN110580188B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910837569.6A CN110580188B (en) 2019-09-05 2019-09-05 Multithreading network allocation method and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910837569.6A CN110580188B (en) 2019-09-05 2019-09-05 Multithreading network allocation method and storage medium

Publications (2)

Publication Number Publication Date
CN110580188A CN110580188A (en) 2019-12-17
CN110580188B true CN110580188B (en) 2023-09-26

Family

ID=68812520

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910837569.6A Active CN110580188B (en) 2019-09-05 2019-09-05 Multithreading network allocation method and storage medium

Country Status (1)

Country Link
CN (1) CN110580188B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111478797A (en) * 2020-03-10 2020-07-31 北京意锐新创科技有限公司 Network distribution method and device suitable for payment equipment
CN111597364B (en) * 2020-03-27 2024-01-30 广联达科技股份有限公司 Engineering quantity calculation middle layer generation method and device, storage medium and electronic equipment
CN113064739A (en) * 2021-03-31 2021-07-02 北京达佳互联信息技术有限公司 Inter-thread communication method and device, electronic equipment and storage medium
CN114007129A (en) * 2021-10-29 2022-02-01 海信视像科技股份有限公司 Display device and network distribution method
CN114007128A (en) * 2021-10-29 2022-02-01 海信视像科技股份有限公司 Display device and network distribution method
CN113810917A (en) * 2021-10-29 2021-12-17 上海庆科信息技术有限公司 Equipment network distribution method and device, storage medium, processor and electronic equipment
CN114258050A (en) * 2021-12-20 2022-03-29 珠海格力电器股份有限公司 Method and module for batch distribution of multiple devices and batch network unbinding

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105843886A (en) * 2016-03-21 2016-08-10 国电南瑞科技股份有限公司 Multi-thread based power grid offline model data query method
CN107391090A (en) * 2017-07-28 2017-11-24 成都优博创通信技术股份有限公司 Multithreading performs method and device
CN109032775A (en) * 2018-06-29 2018-12-18 武汉斗鱼网络科技有限公司 A kind of method, terminal device and storage medium obtaining Task Progress
CN109284190A (en) * 2018-09-20 2019-01-29 中链科技有限公司 A kind of task processing method and device
CN109510743A (en) * 2018-11-16 2019-03-22 中山市力泰电子工业有限公司 A kind of mobile grouping method of intelligent sound box system
CN109582455A (en) * 2018-12-03 2019-04-05 恒生电子股份有限公司 Multithreading task processing method, device and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10318302B2 (en) * 2016-06-03 2019-06-11 Synopsys, Inc. Thread switching in microprocessor without full save and restore of register file

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105843886A (en) * 2016-03-21 2016-08-10 国电南瑞科技股份有限公司 Multi-thread based power grid offline model data query method
CN107391090A (en) * 2017-07-28 2017-11-24 成都优博创通信技术股份有限公司 Multithreading performs method and device
CN109032775A (en) * 2018-06-29 2018-12-18 武汉斗鱼网络科技有限公司 A kind of method, terminal device and storage medium obtaining Task Progress
CN109284190A (en) * 2018-09-20 2019-01-29 中链科技有限公司 A kind of task processing method and device
CN109510743A (en) * 2018-11-16 2019-03-22 中山市力泰电子工业有限公司 A kind of mobile grouping method of intelligent sound box system
CN109582455A (en) * 2018-12-03 2019-04-05 恒生电子股份有限公司 Multithreading task processing method, device and storage medium

Also Published As

Publication number Publication date
CN110580188A (en) 2019-12-17

Similar Documents

Publication Publication Date Title
CN110580188B (en) Multithreading network allocation method and storage medium
WO2019205371A1 (en) Server, message allocation method, and storage medium
US6192388B1 (en) Detecting available computers to participate in computationally complex distributed processing problem
US9686329B2 (en) Method and apparatus for displaying webcast rooms
CN107360310B (en) mobile terminal and resource management method thereof
CN108984266B (en) Virtual machine management method, device and system
CN110502340A (en) A kind of resource dynamic regulation method, device, equipment and storage medium
CN106846040A (en) Virtual present display methods and system in a kind of direct broadcasting room
CN109936593B (en) Method and system for message distribution
CN103002069A (en) Domain name resolution method, device and system
CN111338773A (en) Distributed timed task scheduling method, scheduling system and server cluster
CN110138652B (en) Session updating method and device and client device
CN108537586A (en) Data processing method and device based on user's portrait
CN110555019B (en) Data cleaning method based on service end
CN111340230B (en) Service providing method, device, server and computer readable storage medium
CN106502840A (en) A kind of data back up method, apparatus and system
CN113206877A (en) Session keeping method and device
CN109218817B (en) Method and device for displaying virtual gift prompting message
CN103581273B (en) A kind of distributed system performs method, the apparatus and system of business
CN114244642B (en) Control method and device of equipment, computer readable storage medium and processor
CN106570060B (en) Random extraction method and device for data in information flow
CN109582439B (en) DCN deployment method, device, equipment and computer readable storage medium
CN109948332A (en) A kind of physical machine login password remapping method and device
CN114302478A (en) Matching method of user terminal and network slice, computer device and storage medium
CN112566221A (en) Information synchronization method, device, equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant