CN111240762B - Thread management method, storage medium and electronic device - Google Patents
Thread management method, storage medium and electronic device Download PDFInfo
- Publication number
- CN111240762B CN111240762B CN202010027104.7A CN202010027104A CN111240762B CN 111240762 B CN111240762 B CN 111240762B CN 202010027104 A CN202010027104 A CN 202010027104A CN 111240762 B CN111240762 B CN 111240762B
- Authority
- CN
- China
- Prior art keywords
- data
- threads
- processed
- thread
- period
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000007726 management method Methods 0.000 title claims abstract description 34
- 238000000034 method Methods 0.000 claims abstract description 28
- 238000004590 computer program Methods 0.000 claims description 9
- 230000003247 decreasing effect Effects 0.000 abstract description 3
- 238000004891 communication Methods 0.000 description 7
- 230000005236 sound signal Effects 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000011144 upstream manufacturing Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000006378 damage Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44594—Unloading
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application relates to a thread management method, a storage medium and an electronic device, wherein the method comprises the following steps: the method comprises the steps of obtaining the data volume of data to be processed received in a current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period, judging whether threads need to be destroyed or not according to the data volume of the data to be processed respectively received in each period and the current period in the plurality of periods, obtaining the number of the threads needing to be destroyed when the threads need to be destroyed, and destroying the threads with the number of the threads needing to be destroyed in the current period. The method and the device can continuously keep more threads in a plurality of periods, and avoid the problem of unstable data processing caused by the fact that the threads need to be continuously newly built and destroyed in a plurality of periods due to the fact that the data to be processed received in a plurality of adjacent periods are suddenly increased and decreased or the data to be processed received in a plurality of periods is discontinuous.
Description
Technical Field
The present application relates to the field of thread technologies, and in particular, to a thread management method, a storage medium, and an electronic device.
Background
At present, many systems or electronic devices have a data processing function, and original data generated by an upstream system is uniformly processed and cleaned to obtain real valuable data for displaying, so that the response time of one system is in direct proportion to the efficiency of processing the data.
In the prior art, a scheme for adjusting the number of threads based on a thread pool is disclosed, but in the prior art, if the amount of data generated by an upstream system in a certain time period often has a sudden rise and a sudden fall, or the amount of data generated is intermittent, the current system or electronic device may operate unstably when performing data processing.
Disclosure of Invention
In view of the above problems, the present application provides a thread management method, a storage medium, and an electronic device, which solve the problem in the prior art that the operation of the electronic device is not stable when the amount of received data is not stable
In a first aspect, the present application provides a thread management method, including:
acquiring the data volume of data to be processed received in the current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period;
judging whether the thread needs to be destroyed or not according to the data volume of the data to be processed received in each period of the plurality of periods and the data volume of the data to be processed received in the current period;
and when the threads need to be destroyed, acquiring the number of the threads needing to be destroyed, and destroying the threads with the number of the threads needing to be destroyed in the current period.
Optionally, in the thread management method, according to the data amount of the to-be-processed data received in each of the plurality of cycles and the data amount of the to-be-processed data received in the current cycle, the thread management method includes:
calculating the ratio of the data volume of the data to be processed received in the first period of the plurality of periods to the data volume of the data to be processed respectively received in each other period except the first period and the current period of the plurality of periods;
and judging whether the thread needs to be destroyed or not according to the ratios and preset ratios, wherein the thread needs to be destroyed when the ratios are larger than the preset ratios.
Optionally, in the thread management method, according to the data amount of the to-be-processed data received in each of the plurality of cycles and the data amount of the to-be-processed data received in the current cycle, the thread management method includes:
calculating the difference value between the data volume of the data to be processed received in the first period of the plurality of periods and the data volume of the data to be processed respectively received in each other period except the first period and the current period of the plurality of periods;
and judging whether the thread needs to be destroyed or not according to the difference values and a preset difference value, wherein the thread needs to be destroyed when the difference values are larger than the preset difference value.
Optionally, in the thread management method, the number of threads to be destroyed is obtained according to the following manner:
dividing the data volume of the data to be processed respectively received by each other cycle and the current cycle by the maximum processing volume of each thread to obtain the thread quantity required in each other cycle and the thread quantity required in the current cycle;
and taking the difference value of the thread quantity corresponding to the first period and the maximum required thread quantity in the thread quantities required in a plurality of other periods and the thread quantity required in the current period as the thread quantity required to be destroyed.
Optionally, in the thread management method, destroying the threads of the number of threads to be destroyed in the current period includes:
and destroying the threads with the thread quantity needing to be destroyed in the current period according to the time sequence of finishing the corresponding data to be processed by each thread.
Optionally, in the thread management method, the method further includes:
when the threads do not need to be destroyed, acquiring the number of the threads in the previous period adjacent to the current period;
obtaining the number of required threads in the current period according to the data to be processed received in the current period;
when the number of the demand threads is larger than the number of the threads in the last period, obtaining the number of the threads to be created, and creating the threads corresponding to the number of the threads to be created;
and distributing the data to be processed received in the current period to all threads in the current period.
Optionally, in the thread management method, obtaining the number of threads to be created includes:
and taking the difference value of the number of the demand threads and the number of the threads in the last period as the number of the threads to be created.
Optionally, in the thread management method, allocating the to-be-processed data received in the current cycle to all threads in the current cycle includes:
obtaining the total amount of the data to be processed according to the number of the data to be processed which are not processed in each thread and the number of the received data to be processed;
and distributing the received data to be processed to all threads in the current period according to the total amount of the data to be processed and the number of unprocessed data to be processed in each thread.
In a second aspect, the present application provides a storage medium storing a computer program that, when executed by one or more processors, implements the thread management method described above.
In a third aspect, the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, performs the above-mentioned thread management method.
Compared with the prior art, one or more embodiments in the above scheme can have the following advantages or beneficial effects:
the method comprises the steps of acquiring the data volume of data to be processed received in a current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period, acquiring the number of threads to be destroyed according to the data volume of the data to be processed received in each period in the plurality of periods and the data volume of the data to be processed received in the current period when the threads are needed, and destroying the threads with the number of the threads to be destroyed in the current period so as to continuously keep more threads in the plurality of periods, thereby avoiding unstable data processing caused by the fact that the data to be processed received in the adjacent periods need to be continuously newly built and destroyed in the plurality of periods due to the sudden increase and sudden decrease of the data to be processed received in the adjacent periods or the fact that the data to be processed received in the plurality of periods are interrupted, and the electronic equipment runs unstably.
Drawings
The present application will be described in more detail below on the basis of embodiments and with reference to the accompanying drawings.
Fig. 1 is a flowchart illustrating a thread management method according to an embodiment of the present application.
Fig. 2 is another schematic flow chart of a thread management method according to an embodiment of the present application.
In the drawings, like parts are designated with like reference numerals, and the drawings are not drawn to scale.
Detailed Description
The following detailed description will be provided with reference to the accompanying drawings and embodiments, so that how to apply the technical means to solve the technical problems and achieve the corresponding technical effects can be fully understood and implemented. The embodiments and various features in the embodiments of the present application can be combined with each other without conflict, and the formed technical solutions are all within the scope of protection of the present application.
Example one
Referring to fig. 1, the present application provides a thread management method applicable to an electronic device such as a mobile phone, a computer, or a tablet computer, and the steps S110 to S130 are executed when the application management method is applied to the electronic device.
Step S110: the data volume of the data to be processed received in the current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period are obtained.
The plurality of periods are continuous periods, and the number of the adjacent periods before the current period may be two, three, or five, which is not specifically limited herein and may be set according to actual requirements.
Step S120: and judging whether the thread needs to be destroyed or not according to the data volume of the data to be processed received in each period of the plurality of periods and the data volume of the data to be processed received in the current period.
In the step S120, it may be determined whether to destroy the thread according to a ratio or a difference between the data amount of the to-be-processed data received in the first period of the multiple periods and the data amount of the to-be-processed data received in each of the other periods except the first period of the multiple periods and the data amount of the to-be-processed data received in the current period, where the step is not specifically limited and may be set according to a requirement.
Optionally, in this embodiment, the step may be to calculate a ratio of a data amount of the to-be-processed data received in a first period of the multiple periods to a data amount of the to-be-processed data respectively received in each other period except the first period and the current period of the multiple periods, and determine whether to destroy the thread according to each ratio and a preset ratio, where if each ratio is greater than the preset ratio, it is determined that the thread needs to be destroyed, and if the ratio is smaller than the preset ratio, the thread does not need to be created.
It can be understood that, when the thread needs to be destroyed, the amount of the to-be-processed data received in the first period of the plurality of periods should be greater than the amount of the to-be-processed data received in each of the other periods except the first period of the plurality of periods and the current period, and therefore, the ratio should be a constant greater than 1, for example, 1.1 or 1.12, and the setting may be performed according to an actual requirement, and is not specifically limited herein.
Optionally, in this embodiment, the step S120 may further be: calculating a difference value between the data volume of the data to be processed received in the first period of the multiple periods and the data volume of the data to be processed respectively received in each other period except the first period and the current period of the multiple periods, and judging whether the thread needs to be destroyed according to the difference values and a preset difference value, wherein the thread needs to be destroyed when the difference values are all larger than the preset difference value, and the thread does not need to be destroyed when the difference values are not larger than the preset difference value.
It can be understood that, when the thread needs to be destroyed, the amount of the to-be-processed data received in the first period of the multiple periods should be greater than the amounts of the to-be-processed data received in each of the other periods except the first period of the multiple periods and the current period, and therefore, the preset difference may be, but is not limited to, a value of 20, 50, 100, and the like, and is not specifically limited herein, and may be set according to an actual requirement.
Step S130: and when the threads need to be destroyed, acquiring the number of the threads needing to be destroyed, and destroying the threads with the number of the threads needing to be destroyed in the current period.
The method for acquiring the number of threads to be destroyed may be to acquire the number of threads to be destroyed from a preset database, or may also be to acquire the number of threads to be destroyed according to the number of threads required by the to-be-processed data correspondingly received in each cycle and the number of threads corresponding to the first cycle, where no specific limitation is made here, and the number of threads to be destroyed may be set according to actual requirements.
Optionally, in this embodiment, the step of obtaining the number of threads to be destroyed includes:
dividing the data volume of the data to be processed respectively received by each other cycle and the current cycle by the maximum processing volume of each thread to obtain the thread quantity required in each other cycle and the thread quantity required in the current cycle; and taking the difference value of the thread quantity corresponding to the first period and the maximum required thread quantity in the thread quantities respectively required by a plurality of other periods as the thread quantity required to be destroyed.
The method for destroying the number of threads to be destroyed in the current period may be to destroy the number of threads to be destroyed randomly from a plurality of threads corresponding to the current period, or may be to destroy the number of threads to be destroyed according to the sequence of completing processing of corresponding data to be processed, and the method may be set according to actual requirements.
In order to ensure that the efficiency of destroying threads is improved and the efficiency of processing data to be processed is also ensured, in this embodiment, optionally, the destroying the threads of the number of threads to be destroyed in the current period includes: and destroying the threads with the thread quantity needing to be destroyed in the current period according to the time sequence of finishing the corresponding data to be processed by each thread.
It should be noted that, in this embodiment, the data to be processed received in the current cycle should be further allocated to each thread for processing in the current cycle, and it is understood that the time of the allocation may be allocated before the thread is destroyed, so as to destroy the number of threads that need to be destroyed after the allocation is completed, and the time of the allocation may be after the thread is destroyed, so as to allocate each data to be processed to a plurality of threads after the thread is destroyed after the destruction is completed, and the setting may be performed according to actual requirements, which is not described in detail herein.
Through the arrangement, the purpose that a large number of threads are continuously kept in a plurality of periods is achieved, and the problems that data processing is unstable and electronic equipment runs unstably, and the threads need to be continuously newly built and destroyed in the plurality of periods due to the fact that data to be processed received in the adjacent plurality of periods are suddenly increased and suddenly decreased or the situation that the data to be processed received in the plurality of periods is discontinuous are avoided. Further, when the number of the to-be-processed data received in a plurality of continuous periods is small, the number of the to-be-processed data is considered to be small, and the number of the to-be-processed data received in each period is stable, so that the number of threads is reduced, memory resources are saved, and efficient and stable operation of the electronic equipment is guaranteed.
Referring to fig. 2, in order to make the processing of the data to be processed more efficient by using the thread in the current cycle, in this embodiment, the method further includes:
step S210: and when the threads do not need to be destroyed, acquiring the number of the threads of the previous period adjacent to the current period.
Step S220: and obtaining the number of the required threads in the current period according to the data to be processed received in the current period.
In step S220, the number of required threads in the current cycle may be obtained by dividing the to-be-processed data received in the current cycle by the maximum throughput of each thread.
Step S230: and when the number of the demand threads is larger than the number of the threads in the previous cycle, acquiring the number of the threads to be created, and creating the threads corresponding to the number of the threads to be created.
The method for obtaining the number of the threads to be created may be that the number of the threads to be created is pre-stored in a database associated with the electronic device or a memory of the electronic device, and the pre-stored number of the threads to be created is obtained; the difference between the number of the demand threads and the number of the threads in the last cycle can be used as the number of the threads to be created.
In this embodiment, the step S230 includes: and taking the difference value of the number of the demand threads and the number of the threads in the last period as the number of the threads to be created.
Step S240: and distributing the data to be processed received in the current period to all threads in the current period.
The allocation may be performed by allocating the to-be-processed data received in the current cycle to all threads in the current cycle, or allocating the to-be-processed data according to the number of unprocessed to-be-processed data in each thread and the received to-be-processed data. The setting is not particularly limited and may be performed according to actual requirements.
Optionally, to further improve the processing efficiency of the data to be processed in the current cycle, in this embodiment, the step S240 includes:
and obtaining the total amount of the data to be processed according to the number of the data to be processed which are not processed in each thread and the number of the received data to be processed.
And distributing the received data to be processed to all threads in the current period according to the total amount of the data to be processed and the number of unprocessed data to be processed in each thread.
It can be understood that, when the current time is the end time of the current cycle, the next cycle adjacent to the current cycle is taken as a new current cycle, and the steps S110 to S130 and the steps S210 to S240 are repeatedly performed, so as to effectively ensure the efficiency and stability of the electronic device when processing the data to be processed.
In this embodiment, with the duration corresponding to each cycle being m minutes, the data volume of the to-be-processed data received in the current cycle T and the previous n cycles adjacent to the current cycle are respectively obtained, and whether the data has obvious fluctuation is determined according to the data volume of the to-be-processed data in the current cycle and the previous n cycles adjacent to the current cycle, so as to determine whether to create or destroy the thread, which can be calculated according to the maximum processing volume X of a single thread and the data volume of each cycle being Y, specifically, when the thread needs to be created, the number Z of the threads needing to be created is calculated by (the data volume to be processed Y received in the current cycle-the current thread number S X)/the maximum processing volume X, and when the thread needs to be destroyed, the data volume of the to-be-processed data respectively received in each of the other cycles and the current cycle is respectively divided by the maximum processing volume of each thread, and obtaining the number of threads required in each other period and the number of threads required in the current period, and taking the difference value between the number of threads corresponding to the first period and the maximum required number of threads in the number of threads required in a plurality of other periods and the number of threads required in the current period as the number of threads to be destroyed. And destroying the threads with the thread quantity needing to be destroyed according to the time sequence of finishing the corresponding data to be processed by each thread in the current period.
Example two
The present embodiment also provides a storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application mall, etc., on which a computer program is stored, which when executed by a processor, may implement the method steps of the following thread management method:
acquiring the data volume of data to be processed received in the current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period;
according to the data volume of the data to be processed received in each period of the plurality of periods and the data volume of the data to be processed received in the current period;
and when the threads need to be destroyed, acquiring the number of the threads needing to be destroyed, and destroying the threads with the number of the threads needing to be destroyed in the current period.
The specific embodiment process of the above method steps can be referred to as embodiment one, and the detailed description of this embodiment is not repeated herein.
EXAMPLE III
The embodiment of the present application provides an electronic device, which may be a mobile phone, a computer, or a tablet computer, and the electronic device includes a memory and a processor, where the memory stores a computer program, and the computer program, when executed by the processor, implements the thread management method as described in the first embodiment. It is understood that the electronic device may also include multimedia components, input/output (I/O) interfaces, and communication components.
Wherein, the processor is used for executing all or part of the steps in the thread management method in the first embodiment. The memory is used to store various types of data, which may include, for example, instructions for any application or method in the electronic device, as well as application-related data.
The Processor may be an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a controller, a microcontroller, a microprocessor, or other electronic components, and is configured to perform the thread management method in the first embodiment.
The Memory may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk or optical disk.
The multimedia component may include a screen, which may be a touch screen, and an audio component for outputting and/or inputting an audio signal. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in a memory or transmitted through a communication component. The audio assembly also includes at least one speaker for outputting audio signals.
The I/O interface provides an interface between the processor and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons.
The communication component is used for carrying out wired or wireless communication between the electronic equipment and other equipment. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 405 may include: Wi-Fi module, bluetooth module, NFC module.
In summary, the present application provides a thread management method, a storage medium, and an electronic device, where the method includes: the method comprises the steps of obtaining the data volume of data to be processed received in a current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period, obtaining the number of threads to be destroyed when the threads need to be destroyed according to the data volume of the data to be processed received in each period of the plurality of periods and the data volume of the data to be processed received in the current period, and destroying the threads with the number of the threads to be destroyed in the current period. The method and the device have the advantages that the number of threads is continuously kept in multiple periods, and the problems that data to be processed received in adjacent multiple periods are instable in data processing and electronic equipment is unstable in operation due to the fact that the data to be processed are suddenly increased and suddenly decreased or the data to be processed received in multiple periods are discontinuous are solved. Further, when the number of the to-be-processed data received in a plurality of continuous periods is small, the number of the to-be-processed data is considered to be small, and the number of the to-be-processed data received in each period is stable, so that the number of threads is reduced, memory resources are saved, and efficient and stable operation of the electronic equipment is guaranteed. When the received data in the current period is too large, a thread is created, so that the stability and the efficiency of processing the data to be processed are further improved. Further, after the threads are created, the total amount of the data to be processed is obtained according to the amount of the data to be processed which is not processed in each thread and the amount of the received data to be processed, and the received data to be processed is distributed to all threads in the current period according to the total amount of the data to be processed and the amount of the data to be processed which is not processed in each thread, so that the stability and the efficiency of processing the data to be processed are further improved.
In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed system and method may be implemented in other ways. The system and method embodiments described above are merely illustrative.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Although the embodiments disclosed in the present application are described above, the descriptions are only for the convenience of understanding the present application, and are not intended to limit the present application. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the disclosure as defined by the appended claims.
Claims (9)
1. A method for thread management, the method comprising:
acquiring the data volume of data to be processed received in the current period and the data volume of the data to be processed respectively received in a plurality of periods adjacent to the current period;
judging whether the thread needs to be destroyed or not according to the data volume of the data to be processed received in each period of the plurality of periods and the data volume of the data to be processed received in the current period;
when the threads need to be destroyed, acquiring the number of the threads needing to be destroyed, and destroying the threads with the number of the threads needing to be destroyed in the current period,
when the threads do not need to be destroyed, acquiring the number of the threads in the previous period adjacent to the current period;
dividing the data to be processed received in the current period by the maximum processing capacity of each thread to obtain the number of required threads in the current period;
when the number of the demand threads is larger than the number of the threads in the last period, obtaining the number of the threads to be created, and creating the threads corresponding to the number of the threads to be created;
and distributing the data to be processed received in the current period to all threads in the current period.
2. The thread management method according to claim 1, wherein the step of, according to the data amount of the to-be-processed data received in each of the plurality of cycles and the data amount of the to-be-processed data received in the current cycle, comprises:
calculating the ratio of the data volume of the data to be processed received in the first period of the plurality of periods to the data volume of the data to be processed respectively received in each other period except the first period and the current period of the plurality of periods;
and judging whether the thread needs to be destroyed or not according to the ratios and preset ratios, wherein the thread needs to be destroyed when the ratios are larger than the preset ratios.
3. The thread management method according to claim 1, wherein the step of, according to the data amount of the to-be-processed data received in each of the plurality of cycles and the data amount of the to-be-processed data received in the current cycle, comprises:
calculating the difference value between the data volume of the data to be processed received in the first period of the plurality of periods and the data volume of the data to be processed respectively received in each other period except the first period and the current period of the plurality of periods;
and judging whether the thread needs to be destroyed or not according to the difference values and a preset difference value, wherein the thread needs to be destroyed when the difference values are larger than the preset difference value.
4. The thread management method according to claim 1, wherein the number of threads to be destroyed is obtained by:
dividing the data volume of the data to be processed respectively received in each other period and the current period by the maximum processing volume of each thread to obtain the thread quantity required in each other period and the thread quantity required in the current period;
and taking the difference value of the thread quantity corresponding to the first period and the maximum required thread quantity in the thread quantities required in a plurality of other periods and the thread quantity required in the current period as the thread quantity required to be destroyed.
5. The thread management method according to claim 1, wherein destroying the number of threads that need to be destroyed in the current cycle comprises:
and destroying the threads with the thread quantity needing to be destroyed in the current period according to the time sequence of finishing the corresponding data to be processed by each thread.
6. The thread management method of claim 1, wherein obtaining the number of threads to be created comprises:
and taking the difference value of the number of the demand threads and the number of the threads in the last period as the number of the threads to be created.
7. The method of claim 1, wherein the allocating the pending data received in the current cycle to all threads in the current cycle comprises:
obtaining the total amount of the data to be processed according to the number of the data to be processed which are not processed in each thread and the number of the received data to be processed;
and distributing the received data to be processed to all threads in the current period according to the total amount of the data to be processed and the number of unprocessed data to be processed in each thread.
8. A storage medium storing a computer program, wherein the computer program, when executed by one or more processors, implements a thread management method according to any one of claims 1-7.
9. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program that, when executed by the processor, performs the thread management method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010027104.7A CN111240762B (en) | 2020-01-10 | 2020-01-10 | Thread management method, storage medium and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010027104.7A CN111240762B (en) | 2020-01-10 | 2020-01-10 | Thread management method, storage medium and electronic device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111240762A CN111240762A (en) | 2020-06-05 |
CN111240762B true CN111240762B (en) | 2021-11-23 |
Family
ID=70864204
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010027104.7A Active CN111240762B (en) | 2020-01-10 | 2020-01-10 | Thread management method, storage medium and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111240762B (en) |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP4420324B2 (en) * | 2001-11-01 | 2010-02-24 | ベリサイン・インコーポレイテッド | Fast non-concurrently controlled database |
US9697054B2 (en) * | 2015-09-28 | 2017-07-04 | International Business Machines Corporation | Enhanced management of thread-local objects |
CN109271252B (en) * | 2018-08-29 | 2021-07-16 | 华为技术有限公司 | Method and device for adjusting thread number |
CN110018892A (en) * | 2019-03-12 | 2019-07-16 | 平安普惠企业管理有限公司 | Task processing method and relevant apparatus based on thread resources |
CN110515713A (en) * | 2019-08-13 | 2019-11-29 | 北京安盟信息技术股份有限公司 | A kind of method for scheduling task, equipment and computer storage medium |
-
2020
- 2020-01-10 CN CN202010027104.7A patent/CN111240762B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN111240762A (en) | 2020-06-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110390387B (en) | Assessment of resources used by deep learning applications | |
CN106961454B (en) | File downloading method and device and terminal equipment | |
CN109684080B (en) | Centralized task scheduling method, system and storage medium | |
CN109669775B (en) | Distributed task scheduling method, system and storage medium | |
CN108875387B (en) | Data processing method, device, equipment and medium based on AD system | |
CN112328694A (en) | Method and device for adjusting node trust degree in block chain, electronic equipment and storage medium | |
CN107766528B (en) | Data loading method and terminal for waterfall flow page and computer readable storage medium | |
CN111240762B (en) | Thread management method, storage medium and electronic device | |
CN112817428B (en) | Task running method, device, mobile terminal and storage medium | |
CN111708634B (en) | Port allocation method, device, equipment and readable storage medium | |
CN109753353B (en) | Virtual machine resource allocation method and device and electronic equipment | |
CN111444117B (en) | Method and device for realizing fragmentation of storage space, storage medium and electronic equipment | |
CN112000485A (en) | Task allocation method and device, electronic equipment and computer readable storage medium | |
CN111858542B (en) | Data processing method, device, equipment and computer readable storage medium | |
CN111176641A (en) | Flow node execution method, device, medium and electronic equipment | |
CN112398892A (en) | Service distribution method, device and equipment | |
CN113360120B (en) | Screen driving method and apparatus, electronic apparatus, computer-readable storage medium, and computer program product | |
CN106156169B (en) | Discrete data processing method and device | |
CN113608847A (en) | Task processing method, device, equipment and storage medium | |
CN114186161A (en) | Page display information configuration method, device, equipment and readable storage medium | |
CN110727400A (en) | Flow control method, apparatus, device and medium for distributed storage system | |
CN111290850B (en) | Data storage method, device and equipment | |
CN113127221B (en) | Method, device, equipment and storage medium for limiting message consumption rate | |
CN110737533B (en) | Task scheduling method and device, electronic equipment and storage medium | |
CN112835931A (en) | Method and device for determining data acquisition frequency |
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 |