Course generation method, device, computer equipment and readable storage medium
By configuring the thread pool and thread lock in the server, the problem of long-cycle course generation time is solved, and the course generation efficiency and user experience are improved.
Patent Information
- Application Number
- CN202311666886.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-06
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2043-12-06
AI Technical Summary
When the course cycle exceeds 90 days, the course software needs to be generated day by day in chronological order, resulting in a longer generation time and reduced user experience.
By configuring a thread pool in the server and determining the number of target threads based on the preset number of threads, storing data information in the storage space of the target thread, executing multiple target threads to generate courses, improving generation efficiency, and optimizing resource utilization through thread locks .
It effectively improves the efficiency of course generation, reduces generation time, improves user experience, and maximizes the use of server resources.
Smart Images

Figure CN117745254B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a course generation method, device, computer equipment and readable storage medium. Background Art
[0002] There are often many online training camps that improve users' abilities through courses in the camps. At present, course software with courses usually evaluates user data at the beginning, and then arranges courses for users for a semester or 1-2 months based on their actual data, so as to help users clearly understand what training to do in a certain period of time.
[0003] However, if the course cycle is relatively long, for example, a course of more than 90 days, the course software must be generated day by day in chronological order, resulting in a longer course generation time and reduced user experience. Summary of the invention
[0004] In view of this, the present invention provides a course generation method, apparatus, computer equipment and readable storage medium to solve the problem that if the course cycle is relatively long, for example, a course of more than 90 days, the course software needs to be generated day by day in chronological order, resulting in a long course generation time and reduced user experience.
[0005] In a first aspect, the present invention provides a method for generating a course, the method comprising: obtaining data information of a target object and a preset number of threads of a server; wherein the preset number of threads is used to characterize the number of threads possessed by the server itself, and a thread pool is configured in the server; analyzing and processing the data information to determine target task information; determining a target number of threads based on the preset number of threads; in response to a configuration operation for the thread pool, configuring a plurality of target threads corresponding to the target number of threads to the thread pool based on the configuration operation and the target number of threads; storing the data information in a storage space of the target thread; and executing the target thread to generate a course corresponding to the data information.
[0006] The course generation method provided in this embodiment configures a thread pool in the server, configures a target thread number in the thread pool, then stores data information in the storage space of the target thread, and then executes multiple target threads simultaneously to generate courses corresponding to the data information. Compared with the course software that is generated day by day in chronological order, this method can effectively improve the efficiency of generating courses.
[0007] In an optional embodiment, the data information includes time information and task information; wherein, the data information is analyzed and processed to determine the target information, including: dividing the time information to generate multiple target time periods; based on the target time periods, the mapping table of target time periods and task information, determining the target task information corresponding to each target time period.
[0008] The course generation method provided in this embodiment divides the time information to generate multiple target time periods, and then accurately determines the target task information corresponding to each target time period through the target time periods and a mapping table.
[0009] In an optional implementation, determining the target number of threads based on a preset number of threads includes: determining the target number of threads based on the preset number of threads and a preset multiple.
[0010] The course generation method provided in this embodiment determines the target number of threads by preset multiples. On the one hand, it can improve the efficiency of course generation. On the other hand, if network IO waiting is encountered, it can switch to other target threads for execution, thereby maximizing the use of server resources and reducing the waiting time occupying the server.
[0011] In an optional embodiment, before storing the data information in the target thread, it also includes: in response to an add operation to the thread pool, configuring a thread lock to the thread pool based on the add operation; wherein the thread lock is used to record the number of executions of the target thread; detecting whether the number of executions of the thread lock meets the target number of threads; if the number of executions meets the target number of threads, stopping the execution of the target thread and generating a course corresponding to the data information.
[0012] The course generation method provided in this embodiment can clarify whether each target thread has completed course generation by setting a thread lock. If the execution number meets the target thread number, the target thread is stopped, thereby maximizing the use of server resources.
[0013] In an optional implementation, if the execution quantity does not meet the preset quantity, the target thread of the generated course is locked based on the thread lock until the execution quantity meets the preset quantity, and then the thread lock is opened.
[0014] The course generation method provided in this embodiment, if the execution quantity does not meet the preset quantity, locks the target thread of the generated course based on the thread lock, so that the thread will not continue to occupy server resources, which can effectively improve the efficiency of generating courses.
[0015] In an optional embodiment, the method further includes: storing the generated courses in an array; when the execution quantity meets the preset quantity, sorting the courses according to the date of the courses, and sending the sorted courses to the front end for display.
[0016] The course generation method provided in this embodiment can enable users to clearly understand the tasks that need to be performed in each time period by sorting the generated courses and sending them to the front end for display.
[0017] In an optional implementation, storing the data information in the storage space of the target thread includes: based on the number of target threads, storing the target task information in the storage space of each target thread according to a preset allocation rule.
[0018] The course generation method provided in this embodiment can allocate target task information to each target thread through the number of target threads and preset allocation rules, and store the target task information in the storage space of the corresponding target thread, which can effectively solve the problem of data security and isolation between threads.
[0019] In a second aspect, the present invention provides a device for generating a course, which includes: an acquisition module for acquiring data information of a target object and a preset number of threads of a server; wherein the preset number of threads is used to characterize the number of threads possessed by the server itself, and a thread pool is configured in the server; a processing module for analyzing and processing the data information to determine target task information; a determination module for determining a target number of threads based on the preset number of threads; a configuration module for responding to a configuration operation on the thread pool, and configuring a plurality of target threads corresponding to the target number of threads to the thread pool based on the configuration operation and the target number of threads; a storage module for storing the data information in a storage space of the target thread; and a generation module for executing the target thread and generating a course corresponding to the data information.
[0020] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the course generation method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0021] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the course generation method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 is a flow chart of a method for generating a course according to an embodiment of the present invention;
[0024] Figure 2 is a flow chart of another method for generating a course according to an embodiment of the present invention;
[0025] Figure 3 is a flow chart of another method for generating a course according to an embodiment of the present invention;
[0026] Figure 4 is a structural block diagram of a device for generating a course according to an embodiment of the present invention;
[0027] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0029] Based on relevant technologies, we know that there are often many online training camps that improve users' abilities through courses in the training camps. At present, course software with courses usually evaluates user data at the beginning, and then arranges courses for users for a semester or 1-2 months based on their actual data, so as to help users clearly understand what training to do in a certain period of time.
[0030] However, if the course cycle is relatively long, for example, a course of more than 90 days, the course software must be generated day by day in chronological order, resulting in a longer course generation time and reduced user experience.
[0031] Based on this, the course generation method provided in this embodiment configures a thread pool in the server, and configures a target thread number in the thread pool, then stores the data information in the storage space of the target thread, and then executes multiple target threads at the same time to generate courses corresponding to the data information. Compared with the way that course software is generated day by day in chronological order, this method can effectively improve the efficiency of generating courses.
[0032] According to an embodiment of the present invention, an embodiment of a method for generating a course is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0033] In this embodiment, a method for generating a course is provided, which can be used in computer devices, such as computers, servers, etc. Figure 1 is a flow chart of a method for generating a course according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0034] Step S101, obtaining data information of the target object and the preset number of threads of the server; wherein the preset number of threads is used to represent the number of threads that the server itself has, and a thread pool is configured in the server.
[0035] The target object can be used to represent the user who is conducting the course training, and the target object can be a student, a staff of various professions, etc., which is not specifically limited here.
[0036] The data information can be used to characterize the training needs of the target object. The data information may include time information and task information, such as: losing 10 catties in three months; another example: studying junior high school courses in six months, etc., which are not specifically limited here. Specifically, the data information can be obtained through a questionnaire or by the user filling out a form on the server, which are not specifically limited here.
[0037] The preset number of threads refers to the number of threads that are executed simultaneously in a computer program or process. A thread is the smallest unit that an operating system can schedule. It is a lightweight execution unit used to execute instructions in a program. A program can contain one or more threads, which can be executed in parallel to improve the performance and responsiveness of the program. The preset number of threads can be 5, 10, etc., which can be determined by the type of server and is not specifically limited here.
[0038] A thread pool is a form of multithreading that adds tasks to a queue and then automatically starts them after a thread is created. Thread pool threads are all background threads. Each thread uses the default stack size, runs at the default priority, and is in a multithreaded unit. If a thread is idle in managed code (such as waiting for an event), the thread pool inserts another auxiliary thread to keep all processors busy. If all thread pool threads are always busy, but the queue contains pending work, the thread pool will create another auxiliary thread after a period of time, but the number of threads will never exceed the maximum. Threads that exceed the maximum can be queued, but they will not start until other threads are completed. Specifically, thread pools can be established in servers.
[0039] Step S102, analyzing and processing the data information to determine the target task information.
[0040] The target task information can be used to characterize the daily training goal of the target object. Among them, the target task information can be to lose two pounds in 4 days, or to lose three pounds in 5 days, etc., without specific limitation here. Specifically, the target task information can be determined by analyzing the data information. For example: if the data information is to lose 10 pounds in three months, then the corresponding target task information can be to lose 2 pounds in the first 10 days, and lose 8 pounds in the last 20 days, etc., without specific limitation here.
[0041] Step S103, determining a target number of threads based on a preset number of threads.
[0042] The target number of threads can be used to represent the number of threads that execute data information. The target number of threads is greater than the preset number of threads, and the number can be 20, 30, etc., which can be determined by the preset number of threads and is not specifically limited here. Specifically, the target number of threads in the thread pool can be determined by the preset number of threads of the server itself.
[0043] Step S104, in response to the configuration operation on the thread pool, based on the configuration operation and the target number of threads, a plurality of target threads corresponding to the target number of threads are configured to the thread pool.
[0044] The configuration operation can be an operation generated by a user through a mouse click, keyboard selection or touch screen. When the user issues a configuration operation for the thread pool, the computer device can respond to the user's configuration operation for the thread pool and configure multiple target threads corresponding to the target thread number to the thread pool through the target thread number.
[0045] Step S105, storing the data information in the storage space of the target thread.
[0046] The storage space is used to represent the local thread in the target thread. It can be used to store data information, and when the target thread is processing, the data information is called out through the storage space.
[0047] Step S106, executing the target thread to generate a course corresponding to the data information.
[0048] The course can be used to represent the training course of the target object. Specifically, when executing the target thread, data information can be called from the storage space of the corresponding target thread and the corresponding course can be generated.
[0049] The course generation method provided in this embodiment configures a thread pool in the server, configures a target thread number in the thread pool, then stores data information in the storage space of the target thread, and then executes multiple target threads simultaneously to generate courses corresponding to the data information. Compared with the course software that is generated day by day in chronological order, this method can effectively improve the efficiency of generating courses.
[0050] In this embodiment, a method for generating a course is provided, which can be used in the above-mentioned computer equipment, such as a computer, a server, etc. Figure 2 is a flow chart of a method for generating a course according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0051] Step S201, obtain the data information of the target object and the preset number of threads of the server; wherein the preset number of threads is used to represent the number of threads that the server itself has, and the server is configured with a thread pool. For details, please refer to Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0052] Step S202, analyzing and processing the data information to determine the target task information.
[0053] Specifically, the data information includes time information and task information; the above step S202 includes:
[0054] Step S2021, dividing the time information to generate multiple target time periods.
[0055] Time information can be used to characterize the training time of the target object. The time information can be a specific data, such as: 1 month, 3 months, etc., or a range value, such as: 1 to 2 months, 2 to 3 months, etc., which is not specifically limited here. Specifically, the time information can be obtained by the user through mouse clicks, keyboard clicks, or touching the screen, or through questionnaires, which is not specifically limited here. The target time period can be every day. For example: if the time information is 30 days, then the number of corresponding target time periods is 30.
[0056] Step S2022: determining the target task information corresponding to each target time period based on the target time period, the mapping table of the target time period and the task information.
[0057] The mapping table can be used to characterize the mapping relationship between the target time period and the task information. For example, when the number of target time periods is 10, the corresponding task information may be that the first time period processes task A, the second time period processes task B, and the tenth time period processes task J. Among them, task A, task B, and task J are merged into task information. Specifically, the mapping table can be pre-configured in the server and can be obtained by training the model through a large amount of data, wherein the target time period can be used as the input of the model, and the task information can be used as the output of the model. Therefore, after the target time period is input, the target task information corresponding to each target time period can be automatically generated.
[0058] Step S203, determining a target number of threads based on a preset number of threads.
[0059] Specifically, the above step S203 includes:
[0060] Step S2031, obtaining a preset multiple.
[0061] The preset multiple can be used to represent the multiple of the preset number of threads. The preset multiple can be 2 times, 3 times, etc., which can be determined by the type of the server and is not specifically limited here. Specifically, the preset multiple can be a multiple pre-configured by the user in the server. Preferably, the preset multiple can be 2 times.
[0062] Step S2032: determining a target number of threads based on a preset number of threads and a preset multiple.
[0063] The target number of threads can be used to represent the number of target threads. The target number of threads can be 20, 30, etc., and can be determined by a preset multiple and a preset number of threads, which is not specifically limited here. For example, if the preset number of threads is 10 and the preset multiple is 2, the corresponding target number of threads is 20.
[0064] Step S204: In response to the configuration operation for the thread pool, multiple target threads corresponding to the target number of threads are configured for the thread pool based on the configuration operation and the target number of threads. Figure 1 Step S14 of the illustrated embodiment will not be described in detail here.
[0065] Step S205: store the data information in the storage space of the target thread. Figure 1 Step S105 of the illustrated embodiment will not be described in detail here.
[0066] Step S206, execute the target thread and generate the course corresponding to the data information. Figure 1 Step S106 of the illustrated embodiment will not be described in detail here.
[0067] The course generation method provided in this embodiment divides the time information to generate multiple target time periods, and then accurately determines the target task information corresponding to each target time period through the target time periods and a mapping table.
[0068] In addition, by determining the target number of threads by preset multiples, on the one hand, the efficiency of course generation can be improved. On the other hand, if network IO waits are encountered, execution can be switched to other target threads to maximize the use of server resources and reduce the waiting time occupying the server.
[0069] In an optional embodiment, the above method further includes:
[0070] Step a1, in response to an add operation to the thread pool, configuring a thread lock to the thread pool based on the add operation; wherein the thread lock is used to record the execution quantity of the target thread.
[0071] The adding operation can be an operation generated by a user through a mouse click, keyboard selection or touch screen. When the user issues an adding operation to the thread pool, the computer device can respond to the adding operation of the user to the thread pool and configure a thread lock for the thread pool; wherein the thread lock is used to record the execution quantity of the target thread.
[0072] Step a2, detecting whether the number of thread locks executed meets the target number of threads.
[0073] Step a3: if the execution quantity meets the target thread number, stop executing the target thread and generate the course corresponding to the data information.
[0074] Step a4: If the execution quantity does not meet the preset quantity, the target thread of the generated course is locked based on the thread lock until the execution quantity meets the preset quantity, and then the thread lock is opened.
[0075] When the target thread is executing, after any target thread is completed, that is, after the corresponding course is generated, the execution quantity of the thread lock will increase by one, and the corresponding thread lock will lock the target thread that generates the course until all target threads have generated the course, and the thread lock will be opened.
[0076] Preferably, when the target threads are executed, when any target thread is executed, the execution quantity of the corresponding thread lock will be reduced by one, and the thread lock will not be opened until the execution quantity of the thread lock is zero.
[0077] The course generation method provided in this embodiment can clarify whether each target thread has completed course generation by setting a thread lock. If the execution number meets the target thread number, the target thread is stopped, thereby maximizing the use of server resources.
[0078] In addition, if the execution quantity does not meet the preset quantity, the target thread of the generated course is locked based on the thread lock so that the thread will not continue to occupy server resources, which can effectively improve the efficiency of generating courses.
[0079] In an optional embodiment, the above method further includes:
[0080] Step c1, store the generated courses in an array.
[0081] An array can be used to represent the memory of a server. Specifically, during the execution of a target thread, if the target thread generates a course, the course is stored in an array. For example, target thread A, target thread B, and target thread C, when target thread A generates a course, the course in target thread A can be stored in an array, when target thread B generates a course, the course in target thread B can be stored in an array, and so on, all the courses generated by the target threads are stored in an array.
[0082] Step c2, when the execution quantity meets the preset quantity, the courses are sorted according to the date of the courses, and the sorted courses are sent to the front end for display.
[0083] The front end is also called the web front end. The front end is the foreground part of the website, which runs on browsers such as PCs and mobile terminals to display web pages for users to browse. After all target threads have generated courses, the courses are sorted according to the date of the course, and the sorted courses are sent to the front end for display. Among them, the date can be the order of the target time period. For example: the target time period includes: 5 days, that is, the first day, the second day, the third day, the fourth day and the fifth day, and the corresponding dates can be 2023.11.20, 2023.11.21, 2023.11.22, 2023.11.23 and 2023.11.24.
[0084] The course generation method provided in this embodiment can enable users to clearly understand the tasks that need to be performed in each time period by sorting the generated courses and sending them to the front end for display.
[0085] In an optional implementation, the above step S205 includes: based on the number of target threads, storing the target task information in the storage space of each target thread according to a preset allocation rule.
[0086] The preset allocation rule can be used to characterize the allocation of target task information. Specifically, according to the number of target threads, the target task information is reasonably allocated to the storage space of the target thread. For example, multiple target task information are reduced by 2 jin, reduced by 6 jin, and reduced by 3 jin, respectively, and the number of target threads is 4. The preset allocation rule can be to allocate reduced by 2 jin and reduced by 3 jin to the first target thread and the second target thread, and to allocate reduced by 6 jin to the remaining two target threads.
[0087] The course generation method provided in this embodiment can allocate target task information to each target thread through the number of target threads and preset allocation rules, and store the target task information in the storage space of the corresponding target thread, which can effectively solve the problem of data security and isolation between threads.
[0088] Figure 3 A flow chart of a method for generating a course is shown, Figure 3 As shown, in an optional embodiment, the method for generating a course includes:
[0089] Step S1, start.
[0090] Step S2, obtaining the user's data information, analyzing the data information, evenly distributing the user's goals to be achieved to each day according to the course cycle time, and generating daily goals.
[0091] Step S3, obtaining the number of core threads of the server (Central-Processing-Unit, CPU).
[0092] Step S4, create a thread pool, and set the number of core threads in the thread pool to the number of core threads of the server × 2.
[0093] Step S5, setting the number of days for the course cycle.
[0094] Step S6, storing the daily goal and user data information in the core thread of the corresponding thread pool.
[0095] Step S7, execute the core thread, generate the courses corresponding to the core thread, and store the courses in an array; wherein, each time a core thread generates a course, the number of thread locks is reduced by one.
[0096] Step S8: When the number of thread locks is zero, the course generation is completed.
[0097] Step S9, sort the courses by date and return to the front end.
[0098] Step S10, end.
[0099] The course generation method provided in this embodiment configures a thread pool in the server, configures a target thread number in the thread pool, then stores data information in the storage space of the target thread, and then executes multiple target threads simultaneously to generate courses corresponding to the data information. Compared with the course software that is generated day by day in chronological order, this method can effectively improve the efficiency of generating courses.
[0100] In addition, through the number of target threads and preset allocation rules, the target task information can be allocated to each target thread, and the target task information can be stored in the storage space of the corresponding target thread, which can effectively solve the problem of data security and isolation between threads.
[0101] In the present embodiment, a course generation device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0102] This embodiment provides a course generation device, such as Figure 4 As shown, including:
[0103] An acquisition module 401 is used to acquire data information of a target object and a preset number of threads of a server; wherein the preset number of threads is used to characterize the number of threads possessed by the server itself, and a thread pool is configured in the server; a processing module 402 is used to analyze and process data information to determine target task information; a determination module 403 is used to determine a target number of threads based on the preset number of threads; a configuration module 404 is used to respond to a configuration operation on the thread pool, and based on the configuration operation and the target number of threads, configure a plurality of target threads corresponding to the target number of threads to the thread pool; a storage module 405 is used to store data information in a storage space of a target thread; a generation module 406 is used to execute the target thread and generate a course corresponding to the data information.
[0104] In some optional embodiments, the data information includes time information and task information; wherein the processing module 402 includes: a segmentation unit, used to segment the time information to generate multiple target time periods, and a first determination unit, used to determine the target task information corresponding to each target time period based on a mapping table of target time periods, target time periods and task information.
[0105] In some optional implementations, the determination module 403 includes: an acquisition unit, configured to acquire a preset multiple; and a second determination unit, configured to determine a target number of threads based on the preset number of threads and the preset multiple.
[0106] In some optional embodiments, the device also includes: an adding module, which is used to respond to an adding operation on the thread pool and configure a thread lock to the thread pool based on the adding operation; wherein the thread lock is used to record the number of executions of the target thread; a detection module, which is used to detect whether the number of executions of the thread lock meets the target number of threads; and a stopping module, which is used to stop executing the target thread if the number of executions meets the target number of threads, and generate a course step corresponding to the data information.
[0107] In some optional embodiments, the device further includes: an opening module, which is used to lock the target thread of the generated course based on the thread lock if the execution number does not meet the preset number, and to open the thread lock when the execution number meets the preset number.
[0108] In some optional embodiments, the device also includes: a course storage module for storing the generated courses in an array; a sorting and display module for sorting the courses according to the date of the courses when the execution quantity meets the preset quantity, and sending the sorted courses to the front end for display.
[0109] In some optional implementations, the storage module 405 is used to store the target task information in the storage space of each target thread according to a preset allocation rule based on the number of target threads.
[0110] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0111] The course generation device in this embodiment is presented in the form of a functional unit, where the functional unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0112] The embodiment of the present invention also provides a computer device having the above Figure 5 The generated device of the course shown.
[0113] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0114] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0115] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0116] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0117] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0118] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0119] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0120] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for generating a course, characterized in that: include: Acquire data information of the target object and the preset number of threads of the server; wherein the preset number of threads is used to represent the number of threads that the server itself has, and a thread pool is configured in the server; Analyze and process the data information to determine target task information; Based on the preset number of threads, determining a target number of threads; In response to a configuration operation for the thread pool, based on the configuration operation and the target number of threads, a plurality of target threads corresponding to the target number of threads are configured to the thread pool; Storing the data information in the storage space of the target thread; Execute the target thread to generate a course corresponding to the data information; The data information includes time information and task information; wherein the analyzing and processing the data information to determine the target information includes: The time information is segmented to generate multiple target time periods; wherein the time information is used to represent the training time of the target object, and the time information is a specific data or a range value; Based on the target time period, the target time period and the mapping table of the task information, the target task information corresponding to each target time period is determined; wherein the mapping table is pre-configured in the server and is obtained by training the model through a large amount of data, wherein the target time period can be used as the input of the model, and the task information can be used as the output of the model, and after the target time period is input, the target task information corresponding to each target time period is automatically generated; The storing the data information in the storage space of the target thread includes: Based on the number of the target threads, the target task information is stored in the storage space of each of the target threads according to a preset allocation rule.
2. The method for generating a course according to claim 1, characterized in that: The step of determining a target number of threads based on the preset number of threads includes: Get the preset multiple; The target number of threads is determined based on the preset number of threads and the preset multiple.
3. The method for generating a course according to claim 1, characterized in that: Before storing the data information in the target thread, the method further includes: In response to an add operation to the thread pool, configuring a thread lock for the thread pool based on the add operation; wherein the thread lock is used to record the execution quantity of the target thread; Detecting whether the execution quantity of the thread lock meets the target number of threads; If the execution quantity meets the target number of threads, the execution of the target thread is stopped, and a course corresponding to the data information is generated.
4. The method for generating a course according to claim 3, characterized in that: Also includes: If the execution quantity does not meet the preset quantity, the target thread of the generated course is locked based on the thread lock until the execution quantity meets the preset quantity, and then the thread lock is opened.
5. The method for generating a course according to claim 4, characterized in that: Also includes: Store the generated courses in an array; When the execution quantity meets the preset quantity, the courses are sorted according to the dates of the courses, and the sorted courses are sent to the front end for display.
6. A course generation device, characterized in that: The device comprises: An acquisition module, used for acquiring data information of a target object and a preset number of threads of a server; wherein the preset number of threads is used to represent the number of threads that the server itself has, and a thread pool is configured in the server; A processing module is used to analyze and process the data information to determine target task information; A determination module, configured to determine a target number of threads based on the preset number of threads; A configuration module, configured to, in response to a configuration operation on the thread pool, configure a plurality of target threads corresponding to the target number of threads to the thread pool based on the configuration operation and the target number of threads; A storage module, used for storing the data information in the storage space of the target thread; A generating module, used for executing the target thread and generating a course corresponding to the data information; The data information includes time information and task information; wherein the processing module includes: a segmentation unit, which is used to segment the time information and generate multiple target time periods, and a first determination unit, which is used to determine the target task information corresponding to each target time period based on the target time period, the mapping table of the target time period and the task information; wherein the time information is used to characterize the training time of the target object, the time information is a specific data or a range value, the mapping table is pre-configured in the server, and is obtained by training the model through a large amount of data, wherein the target time period can be used as the input of the model, and the task information can be used as the output of the model, and after the target time period is input, the target task information corresponding to each target time period is automatically generated; The storage module is used to store the target task information in the storage space of each target thread according to a preset allocation rule based on the number of target threads.
7. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the course generation method described in any one of claims 1 to 5 by executing the computer instructions.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the course generation method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method for determining number of concurrent threads in thread pool and related product
CN115168012A
Task processing method and device, electronic equipment and readable storage medium
CN117149414A
