CN110413390A - Thread task processing method, device, server and storage medium - Google Patents
Thread task processing method, device, server and storage medium Download PDFInfo
- Publication number
- CN110413390A CN110413390A CN201910671537.3A CN201910671537A CN110413390A CN 110413390 A CN110413390 A CN 110413390A CN 201910671537 A CN201910671537 A CN 201910671537A CN 110413390 A CN110413390 A CN 110413390A
- Authority
- CN
- China
- Prior art keywords
- task
- thread
- execution
- thread pool
- pool
- 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.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 18
- 238000000034 method Methods 0.000 claims abstract description 45
- 230000002159 abnormal effect Effects 0.000 claims description 22
- 238000012545 processing Methods 0.000 claims description 10
- 230000000007 visual effect Effects 0.000 claims description 5
- 238000004590 computer program Methods 0.000 claims description 4
- 238000010586 diagram Methods 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 230000002093 peripheral effect Effects 0.000 description 3
- 230000005856 abnormality Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
-
- 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5011—Pool
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5018—Thread allocation
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Debugging And Monitoring (AREA)
Abstract
本发明实施例公开了一种线程任务处理方法、装置、服务器及存储介质,所述方法包括:获取任务队列,所述任务队列包括多个第一任务;判断所述第一任务是否被分配对应的线程池;若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数;根据所述配置参数配置线程池,所述线程池包括多个第一线程;调用所述第一线程执行所述第一任务,并记录对应的执行结果。本发明实施例实现了多线程上传文件,实时记录线程任务的执行结果,提高多线程上传系统的稳定性。
Embodiments of the present invention disclose a thread task processing method, device, server, and storage medium. The method includes: acquiring a task queue, where the task queue includes a plurality of first tasks; and determining whether the first tasks are assigned corresponding If the first task is not assigned a corresponding thread pool, obtain the thread pool configuration parameters of the first task; configure a thread pool according to the configuration parameters, and the thread pool includes a plurality of first threads; The first thread is called to execute the first task, and the corresponding execution result is recorded. The embodiment of the present invention realizes the multi-thread uploading of files, records the execution result of the thread task in real time, and improves the stability of the multi-thread uploading system.
Description
技术领域technical field
本发明实施例涉及文件传输领域,尤其涉及一种线程任务处理方法、装置、服务器及存储介质。Embodiments of the present invention relate to the field of file transmission, and in particular, to a thread task processing method, device, server, and storage medium.
背景技术Background technique
安全文件传送协议(Secure File Transfer Protocol,SFTP)为传输文件提供一种安全的网络加密方法。新资金方接入时接入侧技术同事与资金方确认SFTP连接数限制和所需要的线程数,在管理系统中配置资金方SFTP信息即可。开发中过程中需要用多线程去执行的时候,只调用多线程组件提供接口,由组件完成任务。Secure File Transfer Protocol (Secure File Transfer Protocol, SFTP) provides a secure network encryption method for transferring files. When the new funder is connected, the technical colleague on the access side and the funder confirm the limit of the number of SFTP connections and the required number of threads, and configure the funder's SFTP information in the management system. When multi-threading is required for execution during development, only the multi-threaded component is called to provide an interface, and the component completes the task.
由于企业业务发展较快,合作方越来越多,贷后业务相似度比较高,大批量的文件交互做单线程上传到资金方SFTP服务器,数据激增时导致文件上传不及时;多线程上传时需要定制化开发,每次有新资金方接入时需要重写程序来实现新任务的执行,非常影响企业的业务稳定。Due to the rapid development of enterprise business, more and more partners, and high similarity of post-loan business, a large number of file interactions are uploaded to the SFTP server of the funder through a single thread. When the data surges, the file upload is not timely; Customized development is required, and every time a new funder accesses the program, the program needs to be rewritten to implement the new task, which greatly affects the business stability of the enterprise.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供一种线程任务处理方法、装置、服务器及存储介质,以实现多线程上传文件,实时查询线程任务的执行结果,提高多线程上传系统的稳定性。Embodiments of the present invention provide a thread task processing method, device, server and storage medium, so as to realize multi-thread uploading of files, query execution results of thread tasks in real time, and improve the stability of the multi-thread upload system.
第一方面,本发明实施例提供一种线程任务处理方法,包括:In a first aspect, an embodiment of the present invention provides a thread task processing method, including:
获取任务队列,所述任务队列包括多个第一任务;obtaining a task queue, the task queue includes a plurality of first tasks;
判断所述第一任务是否被分配对应的线程池;judging whether the first task is assigned a corresponding thread pool;
若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数;If the first task is not assigned a corresponding thread pool, obtain the thread pool configuration parameters of the first task;
根据所述配置参数配置线程池,所述线程池包括多个第一线程;Configure a thread pool according to the configuration parameter, and the thread pool includes a plurality of first threads;
调用所述第一线程执行所述第一任务,并记录对应的执行结果。The first thread is called to execute the first task, and the corresponding execution result is recorded.
可选的,所述获取配置参数包括:Optionally, the obtaining configuration parameters includes:
调用可视化界面获取用户输入的所述配置参数,所述配置参数包括:通道ID、最大支持线程数、优先级、调度频率、最大异常执行次数和结果通知方式中的一种或多种。Calling the visual interface to obtain the configuration parameters input by the user, the configuration parameters include one or more of: channel ID, maximum number of supported threads, priority, scheduling frequency, maximum abnormal execution times, and result notification mode.
可选的,所述根据所述配置参数配置线程池包括:Optionally, the configuring the thread pool according to the configuration parameter includes:
根据所述通道ID和所述最大支持线程数初始化所述线程池。The thread pool is initialized according to the channel ID and the maximum number of supported threads.
可选的,所述调用所述第一线程执行所述第一任务,包括:Optionally, the invoking the first thread to perform the first task includes:
根据所述第一任务的调度频率和优先级获取第一线程;Obtain the first thread according to the scheduling frequency and priority of the first task;
将所述第一任务放入所述第一线程中执行。Putting the first task into the first thread for execution.
可选的,所述记录对应的执行结果包括:Optionally, the execution result corresponding to the record includes:
判断所述第一线程中的第一任务是否执行成功;Determine whether the first task in the first thread is successfully executed;
若所述第一线程中的第一任务执行失败,确定所述第一线程中的第一任务执行的失败次数;If the execution of the first task in the first thread fails, determining the number of times the execution of the first task in the first thread fails;
若所述失败次数小于或等于所述最大异常执行次数,则将所述第一任务重新加入所述任务队列等待执行。If the number of failures is less than or equal to the maximum number of abnormal executions, the first task is re-added to the task queue for execution.
可选的,所述确定所述第一线程中的第一任务执行的失败次数之后,还包括:Optionally, after the determining the number of times of failures in the execution of the first task in the first thread, the method further includes:
若所述失败次数大于所述最大异常执行次数,则根据所述结果通知方式反馈执行结果。If the number of failures is greater than the maximum number of abnormal executions, the execution result is fed back according to the result notification method.
可选的,所述记录对应的执行结果之后,还包括:Optionally, after the recording of the corresponding execution result, it further includes:
输出能够实时查询所述执行结果的查询地址。A query address capable of querying the execution result in real time is output.
第二方面,本发明实施例提供一种线程任务处理装置,包括:In a second aspect, an embodiment of the present invention provides a thread task processing device, including:
任务队列获取模块,用于获取任务队列,所述任务队列包括多个第一任务;a task queue acquisition module, configured to acquire a task queue, the task queue includes a plurality of first tasks;
线程配置判断模块,用于判断所述第一任务是否被分配对应的线程池;a thread configuration judgment module for judging whether the first task is assigned a corresponding thread pool;
配置参数获取模块,用于若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数;a configuration parameter obtaining module, configured to obtain the thread pool configuration parameters of the first task if the first task is not assigned a corresponding thread pool;
线程池配置模块,用于根据所述配置参数配置线程池,所述线程池包括多个第一线程;a thread pool configuration module, configured to configure a thread pool according to the configuration parameter, where the thread pool includes a plurality of first threads;
任务执行模块,用于调用所述第一线程执行所述第一任务,并记录对应的执行结果。A task execution module, configured to call the first thread to execute the first task, and record the corresponding execution result.
第三方面,本发明实施例提供一种服务器,包括:In a third aspect, an embodiment of the present invention provides a server, including:
一个或多个处理器;one or more processors;
存储装置,用于存储一个或多个程序,storage means for storing one or more programs,
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现本发明任意实施例所提供的线程任务处理方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the thread task processing method provided by any embodiment of the present invention.
第四方面,本发明实施例提供一种计算机可读存储介质,其上存储被分配计算机程序,该程序被处理器执行时实现本发明任意实施例所提供的线程任务处理方法。In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium on which an assigned computer program is stored, and when the program is executed by a processor, implements the thread task processing method provided by any embodiment of the present invention.
本发明实施例在任务队列中的第一任务没有对应的线程池时,根据相应的配置参数配置线程池,使任务队列中的第一任务通过多线程执行,并记录线程任务执行的结果,实现了多线程上传文件,实时查询线程任务的执行结果,提高多线程上传系统的稳定性。In the embodiment of the present invention, when the first task in the task queue does not have a corresponding thread pool, the thread pool is configured according to the corresponding configuration parameters, so that the first task in the task queue is executed through multiple threads, and the execution result of the thread task is recorded, so as to realize Multi-threaded upload files, real-time query thread task execution results, improve the stability of the multi-threaded upload system.
附图说明Description of drawings
图1为本发明实施例一提供的一种线程任务处理方法的流程示意图;1 is a schematic flowchart of a thread task processing method according to Embodiment 1 of the present invention;
图2为本发明实施例二提供的一种线程任务处理方法的流程示意图;2 is a schematic flowchart of a thread task processing method according to Embodiment 2 of the present invention;
图3为本发明实施例三提供的一种线程任务处理装置的结构示意图;3 is a schematic structural diagram of a thread task processing apparatus according to Embodiment 3 of the present invention;
图4为本发明实施例四提供的一种服务器的结构示意图。FIG. 4 is a schematic structural diagram of a server according to Embodiment 4 of the present invention.
具体实施方式Detailed ways
下面结合附图和实施例对本发明作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本发明,而非对本发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明相关的部分而非全部结构。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention. In addition, it should be noted that, for the convenience of description, the drawings only show some but not all structures related to the present invention.
在更加详细地讨论示例性实施例之前应当提到的是,一些示例性实施例被描述成作为流程图描绘的处理或方法。虽然流程图将各步骤描述成顺序的处理,但是其中的许多步骤可以被并行地、并发地或者同时实施。此外,各步骤的顺序可以被重新安排。当其操作完成时处理可以被终止,但是还可以具有未包括在附图中的附加步骤。处理可以对应于方法、函数、规程、子例程、子程序等等。Before discussing the exemplary embodiments in greater detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowchart depicts the steps as a sequential process, many of the steps may be performed in parallel, concurrently, or concurrently. Furthermore, the order of the steps can be rearranged. The process may be terminated when its operation is complete, but may also have additional steps not included in the figures. A process may correspond to a method, function, procedure, subroutine, subroutine, or the like.
此外,术语“第一”、“第二”等可在本文中用于描述各种方向、动作、步骤或元件等,但这些方向、动作、步骤或元件不受这些术语限制。这些术语仅用于将第一个方向、动作、步骤或元件与另一个方向、动作、步骤或元件区分。术语“第一”、“第二”等不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本发明的描述中,“多个”、“批量”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。Furthermore, the terms "first," "second," etc. may be used herein to describe various directions, acts, steps or elements, etc., but are not limited by these terms. These terms are only used to distinguish a first direction, act, step or element from another direction, act, step or element. The terms "first", "second", etc. should not be understood as indicating or implying relative importance or implying the number of indicated technical features. Thus, a feature defined as "first" or "second" may expressly or implicitly include one or more of that feature. In the description of the present invention, "plurality" and "batch" mean at least two, such as two, three, etc., unless otherwise expressly and specifically defined.
实施例一Example 1
图1为本发明实施例一提供的一种线程任务处理方法的流程示意图,可适用于使用多线程上传文件,该方法可以由线程任务处理装置来执行,该装置可以采用软件和/或硬件的方式实现,并可集成在服务器。如图1所示,该方法包括:1 is a schematic flowchart of a thread task processing method provided in Embodiment 1 of the present invention, which is applicable to uploading files using multiple threads. way to achieve, and can be integrated in the server. As shown in Figure 1, the method includes:
S110、获取任务队列,所述任务队列包括多个第一任务。S110. Acquire a task queue, where the task queue includes a plurality of first tasks.
具体的,任务队列是指存放待处理任务的队列,即任务队列中包含多个待处理的第一任务。第一任务可以是任意需要执行的任务类型,例如接口API请求、上传文件、下载文件等。Specifically, the task queue refers to a queue for storing tasks to be processed, that is, the task queue includes a plurality of first tasks to be processed. The first task may be any task type that needs to be executed, such as an interface API request, uploading a file, downloading a file, and the like.
S120、判断所述第一任务是否被分配对应的线程池。S120. Determine whether the first task is allocated a corresponding thread pool.
具体的,线程池是一种多线程处理形式,线程池中包含多个线程,这些线程用来执行任务队列中的第一任务。若当前第一任务在此前已经被执行过,那么说明已经存在相应的线程池,则只需将当前需要执行的第一任务放入已有线程池中的线程进行执行即可。若当前第一任务为一个新的任务类型,没有现有的线程池来执行该第一任务,则需要创建一个新的线程池,以使该第一任务能够执行。Specifically, the thread pool is a form of multi-thread processing, and the thread pool includes multiple threads, and these threads are used to execute the first task in the task queue. If the current first task has been executed before, it means that a corresponding thread pool already exists, and it is only necessary to put the first task that needs to be executed currently into the thread in the existing thread pool for execution. If the current first task is a new task type and there is no existing thread pool to execute the first task, a new thread pool needs to be created so that the first task can be executed.
S130、若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数。S130. If the first task is not allocated a corresponding thread pool, acquire the thread pool configuration parameters of the first task.
具体的,配置参数是用来创建新的线程池或执行第一任务的一些参数,包括通道ID、最大支持线程数、优先级、调度频率、最大异常执行次数和结果通知方式中的一种或多种。这些配置参数通过可视化界面由用户输入,在不重写程序的情况下可随时更改。Specifically, the configuration parameters are some parameters used to create a new thread pool or execute the first task, including one or more of the channel ID, the maximum number of supported threads, the priority, the scheduling frequency, the maximum number of abnormal executions, and the result notification method. variety. These configuration parameters are entered by the user through a visual interface and can be changed at any time without rewriting the program.
本实施例中,通道ID是用来创建新的线程池的通道地址。最大支持线程数表示能够同时运行的线程的最大数量。优先级用来表示第一任务的优先程度。调度频率是指将第一任务从队列中放入线程池的线程中的频率。最大异常执行次数是允许第一任务执行失败的最大次数。结果通知方式则是线程任务执行失败时的通知方式。In this embodiment, the channel ID is a channel address used to create a new thread pool. Maximum supported threads represents the maximum number of threads that can run concurrently. Priority is used to indicate the priority of the first task. Scheduling frequency refers to the frequency at which the first task is put from the queue into the thread of the thread pool. The maximum number of abnormal executions is the maximum number of times the first task is allowed to fail. The result notification method is the notification method when the thread task execution fails.
S140、根据所述配置参数配置线程池,所述线程池包括多个第一线程。S140. Configure a thread pool according to the configuration parameter, where the thread pool includes a plurality of first threads.
具体的,获取配置参数后则进行线程池的配置,即创建一个新的线程池用来执行新的第一任务。线程池中包含多个第一线程,用来执行新的第一任务。Specifically, after the configuration parameters are acquired, the thread pool is configured, that is, a new thread pool is created to execute a new first task. The thread pool includes a plurality of first threads for executing new first tasks.
可选的,根据配置参数配置线程池可以是:根据所述通道ID和所述最大支持线程数初始化所述线程池。Optionally, configuring the thread pool according to configuration parameters may be: initializing the thread pool according to the channel ID and the maximum number of supported threads.
具体的,通道ID是用来创建新的线程池的通道地址,由用户分配。最大支持线程数表示能够同时运行的线程的最大数量,其小于或等于通道ID所对应的通道能支持并发的最大线程数。例如,通道ID为1112,通知支持并发的最大线程数为10,最大支持线程数可以为10或9,即表示,在通道ID为1112的通道内创建了一个最多能支持10或9个线程并发进行的线程池。Specifically, the channel ID is the channel address used to create a new thread pool, which is assigned by the user. The maximum number of supported threads indicates the maximum number of threads that can run at the same time, which is less than or equal to the maximum number of concurrent threads that the channel corresponding to the channel ID can support. For example, if the channel ID is 1112, the maximum number of threads supported by notification is 10, and the maximum number of supported threads can be 10 or 9, which means that a channel with channel ID of 1112 is created that can support up to 10 or 9 concurrent threads. Thread pool to do.
S150、调用所述第一线程执行所述第一任务,并记录对应的执行结果。S150. Invoke the first thread to execute the first task, and record the corresponding execution result.
具体的,创建线程池之后,将第一任务放入第一线程中执行,并记录对应的执行结果。对应的执行结果包括执行成功、执行失败以及执行失败的次数。Specifically, after the thread pool is created, the first task is put into the first thread for execution, and the corresponding execution result is recorded. The corresponding execution results include execution success, execution failure, and the number of execution failures.
可选的,调用所述第一线程执行所述第一任务的一种方法可以是:Optionally, a method for invoking the first thread to perform the first task may be:
根据所述第一任务的调度频率和优先级获取第一线程;Obtain the first thread according to the scheduling frequency and priority of the first task;
将所述第一任务放入所述第一线程中执行。Putting the first task into the first thread for execution.
具体的,优先级用来表示第一任务的优先程度,第一任务的优先级越高,越会被优先执行。默认情况下,采用“先进先出”的方式执行多个第一任务,即先进入任务队列里的任务被优先放入第一线程中执行。在特殊情况下,有些第一任务的处理紧急程度比其他的更高,则可通过设置优先级的方式先执行最紧急的第一任务,再执行次要紧急的第一任务。可选的,一种设置优先级的方法为:按10、8、5、3的方式设置第一任务的优先级,其中当第一任务的优先级为10时,其优先级最高,当第一任务没有设置优先级时,默认其优先级为5。Specifically, the priority is used to indicate the priority of the first task, and the higher the priority of the first task, the more preferentially it will be executed. By default, multiple first tasks are executed in a "first-in, first-out" manner, that is, the tasks that enter the task queue first are prioritized into the first thread for execution. Under special circumstances, some first tasks are more urgent than others, the most urgent first task can be executed first, and then the less urgent first task can be executed by setting the priority. Optionally, a method for setting the priority is: setting the priority of the first task in the manner of 10, 8, 5, and 3, wherein when the priority of the first task is 10, its priority is the highest, and when the priority of the first task is 10, the priority is the highest. When a task has no priority set, the default priority is 5.
调度频率是指将第一任务从队列中放入线程池的线程中的频率,即第一任务的获取频率,调度频率可以根据第一任务的执行周期进行预估和调整。例如,第一任务的执行周期为0.5s,调度频率可以设置为2次/s。The scheduling frequency refers to the frequency of putting the first task from the queue into the thread of the thread pool, that is, the acquisition frequency of the first task, and the scheduling frequency can be estimated and adjusted according to the execution period of the first task. For example, the execution period of the first task is 0.5s, and the scheduling frequency can be set to 2 times/s.
本发明实施例一提供的线程任务处理方法,在任务队列中的第一任务没有对应的线程池时,根据相应的配置参数配置线程池,使任务队列中的第一任务通过多线程执行,并记录线程任务执行的结果,实现了多线程上传文件,实时记录线程任务的执行结果,提高多线程上传系统的稳定性。In the thread task processing method provided in Embodiment 1 of the present invention, when the first task in the task queue does not have a corresponding thread pool, the thread pool is configured according to the corresponding configuration parameters, so that the first task in the task queue is executed by multiple threads, and Record the results of thread task execution, realize multi-thread uploading files, record the execution results of thread tasks in real time, and improve the stability of the multi-thread upload system.
实施例二Embodiment 2
图2为本发明实施例二提供的一种线程任务处理方法的流程示意图,本实施例是在上述实施例的基础上的进一步细化。如图2所示,该方法包括:FIG. 2 is a schematic flowchart of a thread task processing method according to Embodiment 2 of the present invention. This embodiment is a further refinement on the basis of the foregoing embodiment. As shown in Figure 2, the method includes:
S200、获取任务队列,所述任务队列包括多个第一任务。S200. Acquire a task queue, where the task queue includes a plurality of first tasks.
具体的,任务队列是指存放待处理任务的队列,即任务队列中包含多个待处理的第一任务。第一任务可以是任意需要执行的任务类型,例如接口API请求、上传文件、下载文件等。Specifically, the task queue refers to a queue for storing tasks to be processed, that is, the task queue includes a plurality of first tasks to be processed. The first task may be any task type that needs to be executed, such as an interface API request, uploading a file, downloading a file, and the like.
S210、判断所述第一任务是否被分配对应的线程池。S210. Determine whether the first task is allocated a corresponding thread pool.
具体的,线程池是一种多线程处理形式,线程池中包含多个线程,这些线程用来执行任务队列中的第一任务。若当前第一任务在此前已经被执行过,那么说明已经存在相应的线程池,则只需将当前需要执行的第一任务放入已有线程池中的线程进行执行即可。若当前第一任务为一个新的任务类型,没有现有的线程池来执行该第一任务,则需要创建一个新的线程池,以使该第一任务能够执行。Specifically, the thread pool is a form of multi-thread processing, and the thread pool includes multiple threads, and these threads are used to execute the first task in the task queue. If the current first task has been executed before, it means that a corresponding thread pool already exists, and it is only necessary to put the first task that needs to be executed currently into the thread in the existing thread pool for execution. If the current first task is a new task type and there is no existing thread pool to execute the first task, a new thread pool needs to be created so that the first task can be executed.
S220、若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数。S220. If the first task is not allocated a corresponding thread pool, acquire the thread pool configuration parameters of the first task.
具体的,配置参数是用来创建新的线程池或执行第一任务的一些参数,包括通道ID、最大支持线程数、优先级、调度频率、最大异常执行次数和结果通知方式中的一种或多种。这些配置参数通过可视化界面由用户输入,在不重写程序的情况下可随时更改。Specifically, the configuration parameters are some parameters used to create a new thread pool or execute the first task, including one or more of the channel ID, the maximum number of supported threads, the priority, the scheduling frequency, the maximum number of abnormal executions, and the result notification method. variety. These configuration parameters are entered by the user through a visual interface and can be changed at any time without rewriting the program.
本实施例中,通道ID是用来创建新的线程池的通道地址。最大支持线程数表示能够同时运行的线程的最大数量。优先级用来表示第一任务的优先程度。调度频率是指将第一任务从队列中放入线程池的线程中的频率。最大异常执行次数是允许线程任务执行失败的最大次数。结果通知方式则是线程任务执行失败时的通知方式。In this embodiment, the channel ID is a channel address used to create a new thread pool. Maximum supported threads represents the maximum number of threads that can run concurrently. Priority is used to indicate the priority of the first task. Scheduling frequency refers to the frequency at which the first task is put from the queue into the thread of the thread pool. The maximum number of exception executions is the maximum number of times the thread task execution is allowed to fail. The result notification method is the notification method when the thread task execution fails.
S230、根据所述配置参数配置线程池,所述线程池包括多个第一线程。S230. Configure a thread pool according to the configuration parameter, where the thread pool includes a plurality of first threads.
具体的,获取配置参数后则进行线程池的配置,即创建一个新的线程池用来执行新的第一任务。线程池中包含多个第一线程,用来执行新的第一任务。Specifically, after the configuration parameters are acquired, the thread pool is configured, that is, a new thread pool is created to execute a new first task. The thread pool includes a plurality of first threads for executing new first tasks.
可选的,根据配置参数配置线程池的一种方法可以是:根据所述通道ID和所述最大支持线程数初始化所述线程池。Optionally, a method for configuring a thread pool according to a configuration parameter may be: initializing the thread pool according to the channel ID and the maximum number of supported threads.
具体的,通道ID是用来创建新的线程池的通道地址,由用户分配。最大支持线程数表示能够同时运行的线程的最大数量,其小于或等于通道ID所对应的通道能支持并发的最大线程数。例如,通道ID为1112,通知支持并发的最大线程数为10,最大支持线程数可以为10或9,即表示,在通道ID为1112的通道内创建了一个最多能支持10或9个线程并发进行的线程池。Specifically, the channel ID is the channel address used to create a new thread pool, which is assigned by the user. The maximum number of supported threads indicates the maximum number of threads that can run at the same time, which is less than or equal to the maximum number of concurrent threads that the channel corresponding to the channel ID can support. For example, if the channel ID is 1112, the maximum number of threads supported by notification is 10, and the maximum number of supported threads can be 10 or 9, which means that a channel with channel ID of 1112 is created that can support up to 10 or 9 concurrent threads. Thread pool to do.
S240、调用所述第一线程执行所述第一任务。S240. Invoke the first thread to execute the first task.
具体的,创建线程池之后,将第一任务放入第一线程中执行。Specifically, after the thread pool is created, the first task is put into the first thread for execution.
可选的,调用所述第一线程执行所述第一任务的一种方法可以是:Optionally, a method for invoking the first thread to perform the first task may be:
根据所述第一任务的调度频率和优先级获取第一线程;Obtain the first thread according to the scheduling frequency and priority of the first task;
将所述第一任务放入所述第一线程中执行。Putting the first task into the first thread for execution.
具体的,优先级用来表示第一任务的优先程度,第一任务的优先级越高,越会被优先执行。默认情况下,采用“先进先出”的方式执行多个第一任务,即先进入任务队列的任务被优先放入第一线程中执行。在特殊情况下,有些第一任务的处理紧急程度比其他第一任务更高,则可通过设置优先级的方式先执行最紧急的第一任务,再执行次要紧急的第一任务。可选的,一种设置优先级的方法为:按10、8、5、3的方式设置第一任务的优先级,其中当第一任务的优先级为10时,其优先级最高,当第一任务没有设置优先级时,默认其优先级为5。Specifically, the priority is used to indicate the priority of the first task, and the higher the priority of the first task, the more preferentially it will be executed. By default, multiple first tasks are executed in a "first-in, first-out" manner, that is, the tasks that enter the task queue first are prioritized into the first thread for execution. Under special circumstances, some first tasks are more urgently processed than other first tasks, the most urgent first task can be executed first, and then the less urgent first task can be executed by setting the priority. Optionally, a method for setting the priority is: setting the priority of the first task in the manner of 10, 8, 5, and 3, wherein when the priority of the first task is 10, its priority is the highest, and when the priority of the first task is 10, the priority is the highest. When a task has no priority set, the default priority is 5.
调度频率是指将第一任务从队列中放入线程池的线程中的频率,即第一任务的获取频率,调度频率可以根据第一任务的执行周期进行预估和调整。例如,第一任务的执行周期为0.5s,调度频率可以设置为2次/s。The scheduling frequency refers to the frequency of putting the first task from the queue into the thread of the thread pool, that is, the acquisition frequency of the first task, and the scheduling frequency can be estimated and adjusted according to the execution period of the first task. For example, the execution period of the first task is 0.5s, and the scheduling frequency can be set to 2 times/s.
S250、判断所述第一线程中的第一任务是否执行成功。S250. Determine whether the first task in the first thread is successfully executed.
具体的,第一线程中的第一任务可以称为第一线程任务,第一线程任务若执行成功,则说明第一线程任务在执行的过程中没有出现异常或故障,若执行失败,则可能是出现了某种异常原因,例如网络故障等。Specifically, the first task in the first thread may be called the first thread task. If the first thread task is successfully executed, it means that there is no abnormality or failure during the execution of the first thread task. If the execution fails, it may be There is some abnormal reason, such as network failure, etc.
S260、若所述第一线程中的第一任务执行失败,确定所述第一线程中的第一任务执行的失败次数。S260. If the execution of the first task in the first thread fails, determine the number of times the execution of the first task in the first thread fails.
具体的,若第一线程任务执行失败,应该统计其失败次数,通过其失败次数判断执行步骤S270或步骤S280。Specifically, if the execution of the first thread task fails, the number of failures should be counted, and step S270 or step S280 should be executed according to the number of failures.
S270、若所述失败次数小于或等于所述最大异常执行次数,则将所述第一任务重新加入所述任务队列等待执行。S270. If the number of failures is less than or equal to the maximum number of abnormal executions, re-add the first task to the task queue for execution.
具体的,最大异常执行次数是允许第一线程任务执行失败的最大次数。若第一线程任务执行失败的次数小于或等于最大异常执行次数,说明第一线程任务执行失败的次数在允许的范围内,将第一任务加入任务队列重新执行一遍,则有可能消除异常原因执行成功。例如,第一线程任务执行时发生了瞬间的网络故障而造成第一线程任务执行失败,通过将第一任务重新加入任务队列再执行一遍则可以执行成功,提高了第一线程任务的执行成功率。Specifically, the maximum number of abnormal executions is the maximum number of times the task of the first thread is allowed to fail in execution. If the number of failures of the first thread task execution is less than or equal to the maximum number of abnormal execution times, it means that the number of times the first thread task fails to execute is within the allowable range. If the first task is added to the task queue and executed again, it is possible to eliminate the abnormal cause execution. success. For example, if a momentary network failure occurs during the execution of the first thread task, which causes the first thread task to fail to execute, the first task can be successfully executed by adding the first task back to the task queue and executing it again, which improves the execution success rate of the first thread task. .
可选的,在将执行失败的第一线程中的第一任务重新加入队列时,可以将该第一任务的优先级提高,以使该第一任务再次执行时能够被优先执行。Optionally, when the first task in the first thread that fails to be executed is rejoined to the queue, the priority of the first task may be increased, so that the first task can be preferentially executed when the first task is executed again.
S280、若所述失败次数大于所述最大异常执行次数,则根据所述结果通知方式反馈执行结果。S280. If the number of failures is greater than the maximum number of abnormal executions, the execution result is fed back according to the result notification method.
具体的,若第一线程任务执行失败的次数大于最大异常执行次数,说明第一任务的执行流程发生了某种不可自行修复的异常,需要进行人工调试,则根据结果通知方式反馈第一线程任务执行失败的总次数。结果通知方式是反馈异常结果的一种方式,例如以消息的方式通知设置的异常处理人,或者生成故障报告保存到设置的目标文件夹下。Specifically, if the number of execution failures of the first thread task is greater than the maximum abnormal execution times, it means that some kind of abnormality that cannot be repaired by itself has occurred in the execution process of the first task, and manual debugging is required, and the first thread task is fed back according to the result notification method. The total number of execution failures. The result notification method is a method of feeding back abnormal results, such as notifying the set exception handler in the form of a message, or generating a fault report and saving it to the set target folder.
S290、输出能够实时查询所述执行结果的查询地址。S290. Output a query address capable of querying the execution result in real time.
具体的,查询地址是可以显示执行结果的一个接口地址,例如某个显示器的接口地址。通过查询地址可以实时监测第一线程任务的执行情况,从而在第一线程的第一任务执行失败时及时采取相应的措施,提高系统运行的稳定性。Specifically, the query address is an interface address that can display the execution result, such as the interface address of a display. By querying the address, the execution of the task of the first thread can be monitored in real time, so that corresponding measures can be taken in time when the execution of the first task of the first thread fails to improve the stability of the system operation.
本发明实施例二通过记录执行结果,当第一线程中的第一任务执行失败的次数在最大异常执行次数范围内时,将第一任务重新放入任务队列再次执行,当第一线程中的第一任务执行失败的次数超过最大异常执行次数时,通过结果通知方式反馈执行结果,并且输出能够实时查询所述执行结果的查询地址,实现了实时监测第一任务的执行结果,在第一任务执行失败时能够及时采取对应措施,提高第一任务的执行成功率和系统运行的稳定性。In the second embodiment of the present invention, by recording the execution results, when the number of execution failures of the first task in the first thread is within the range of the maximum abnormal execution times, the first task is put back into the task queue for execution again. When the number of execution failures of the first task exceeds the maximum number of abnormal executions, the execution result is fed back through the result notification method, and a query address that can query the execution result in real time is output, which realizes real-time monitoring of the execution result of the first task. When the execution fails, corresponding measures can be taken in time to improve the execution success rate of the first task and the stability of the system operation.
实施例三Embodiment 3
图3为本发明实施例三提供的一种线程任务处理装置的结构示意图,本实施例可适用于使用多线程上传文件。该装置可以采用软件和/或硬件的方式实现,并可集成在服务器上。本发明实施例所提供的线程任务处理装置可执行本发明任意实施例所提供的线程任务处理方法,具备执行方法相应的功能模块和有益效果。本发明实施例三中未详尽描述的内容可以参考本发明任意方法实施例中的描述。FIG. 3 is a schematic structural diagram of a thread task processing apparatus according to Embodiment 3 of the present invention. This embodiment is applicable to uploading files using multiple threads. The device can be implemented in software and/or hardware, and can be integrated on a server. The thread task processing apparatus provided by the embodiment of the present invention can execute the thread task processing method provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method. For the content not described in detail in Embodiment 3 of the present invention, reference may be made to the description in any method embodiment of the present invention.
如图3所示,本发明实施例三提供的线程任务处理装置300包括:As shown in FIG. 3 , the thread task processing apparatus 300 provided in Embodiment 3 of the present invention includes:
任务队列获取模块310,用于获取任务队列,所述任务队列包括多个第一任务;A task queue acquiring module 310, configured to acquire a task queue, where the task queue includes a plurality of first tasks;
线程配置判断模块320,用于判断所述第一任务是否被分配对应的线程池;a thread configuration judging module 320, configured to judge whether the first task is assigned a corresponding thread pool;
配置参数获取模块330,用于若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数;A configuration parameter obtaining module 330, configured to obtain a thread pool configuration parameter of the first task if the first task is not assigned a corresponding thread pool;
线程池配置模块340,用于根据所述配置参数配置线程池,所述线程池包括多个第一线程;a thread pool configuration module 340, configured to configure a thread pool according to the configuration parameter, where the thread pool includes a plurality of first threads;
任务执行模块350,用于调用所述第一线程执行所述第一任务,并记录对应的执行结果。The task execution module 350 is configured to call the first thread to execute the first task, and record the corresponding execution result.
进一步的,配置参数获取模块330还用于调用可视化界面获取用户输入的所述配置参数,所述配置参数包括:通道ID、最大支持线程数、优先级、调度频率、最大异常执行次数和结果通知方式中的一种或多种。Further, the configuration parameter obtaining module 330 is further configured to call the visual interface to obtain the configuration parameters input by the user, the configuration parameters include: channel ID, maximum number of supported threads, priority, scheduling frequency, maximum abnormal execution times and result notification one or more of the ways.
进一步的,线程池配置模块340包括:Further, the thread pool configuration module 340 includes:
线程池初始化单元,用于根据所述通道ID和所述最大支持线程数初始化所述线程池。A thread pool initialization unit, configured to initialize the thread pool according to the channel ID and the maximum number of supported threads.
进一步的,任务执行模块350包括:Further, the task execution module 350 includes:
第一线程获取单元,用于根据所述第一任务的调度频率和优先级获取第一线程;a first thread acquiring unit, configured to acquire the first thread according to the scheduling frequency and priority of the first task;
第一任务执行单元,用于将所述第一任务放入所述第一线程中执行。A first task execution unit, configured to put the first task into the first thread for execution.
进一步的,任务执行模块350还包括:Further, the task execution module 350 also includes:
第一任务执行结果判断单元,用于判断所述第一线程中的第一任务是否执行成功;a first task execution result judgment unit, configured to judge whether the first task in the first thread is successfully executed;
第一任务执行失败次数判断单元,用于若所述第一线程中的第一任务执行失败,确定所述第一线程中的第一任务执行的失败次数;a first task execution failure times judgment unit, configured to determine the failure times of the first task execution in the first thread if the first task execution in the first thread fails;
第一任务重建单元,用于若所述失败次数小于或等于所述最大异常执行次数,则将所述第一任务重新加入所述任务队列等待执行。A first task rebuilding unit, configured to re-add the first task to the task queue for execution if the number of failures is less than or equal to the maximum number of abnormal executions.
进一步的,任务执行模块350还包括:Further, the task execution module 350 also includes:
执行结果反馈单元,用于若所述失败次数大于所述最大异常执行次数,则根据所述结果通知方式反馈执行结果。An execution result feedback unit, configured to feed back an execution result according to the result notification method if the number of failures is greater than the maximum number of abnormal executions.
进一步的,线程任务处理装置300还包括:Further, the thread task processing apparatus 300 further includes:
查询地址输出模块,用于输出能够实时查询所述执行结果的查询地址。The query address output module is used for outputting the query address that can query the execution result in real time.
本发明实施例三通过在任务队列中的第一任务没有对应的线程池时,根据相应的配置参数配置线程池,使任务队列中的第一任务通过多线程执行,并记录线程任务执行的结果,实现了多线程上传文件,实时查询线程任务的执行结果,提高多线程上传的业务稳定性。In the third embodiment of the present invention, when the first task in the task queue does not have a corresponding thread pool, the thread pool is configured according to the corresponding configuration parameters, so that the first task in the task queue is executed through multiple threads, and the execution result of the thread task is recorded , to achieve multi-threaded uploading of files, real-time query of the execution results of thread tasks, and improve the business stability of multi-threaded uploading.
实施例四Embodiment 4
图4是本发明实施例四提供的一种服务器的结构示意图。图4示出了适于用来实现本发明实施方式的示例性服务器412的框图。图4显示的服务器412仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。FIG. 4 is a schematic structural diagram of a server according to Embodiment 4 of the present invention. Figure 4 shows a block diagram of an exemplary server 412 suitable for use in implementing embodiments of the present invention. The server 412 shown in FIG. 4 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present invention.
如图4所示,服务器412以通用服务器的形式表现。服务器412的组件可以包括但不限于:一个或者多个处理器416,存储装置428,连接不同系统组件(包括存储装置428和处理器416)的总线418。As shown in FIG. 4, server 412 takes the form of a general server. Components of server 412 may include, but are not limited to, one or more processors 416, storage 428, and a bus 418 connecting various system components including storage 428 and processor 416.
总线418表示几类总线结构中的一种或多种,包括存储装置总线或者存储装置控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(Industry SubversiveAlliance,ISA)总线,微通道体系结构(Micro Channel Architecture,MAC)总线,增强型ISA总线、视频电子标准协会(Video Electronics Standards Association,VESA)局域总线以及外围组件互连(Peripheral Component Interconnect,PCI)总线。Bus 418 represents one or more of several types of bus structures, including a storage device bus or storage device controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include, but are not limited to, Industry Subversive Alliance (ISA) bus, Micro Channel Architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (Video Electronics Standards Association) , VESA) local bus and peripheral component interconnect (Peripheral Component Interconnect, PCI) bus.
服务器412典型地包括多种计算机系统可读介质。这些介质可以是任何能够被服务器412访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。Server 412 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by server 412, including volatile and non-volatile media, removable and non-removable media.
存储装置428可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(Random Access Memory,RAM)430和/或高速缓存存储器432。服务器412可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统434可以用于读写不可移动的、非易失性磁介质(图4未显示,通常称为“硬盘驱动器”)。尽管图4中未示出,可以提供用于对可移动非易失性磁盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘,例如只读光盘(Compact Disc Read-Only Memory,CD-ROM),数字视盘(Digital Video Disc-Read Only Memory,DVD-ROM)或者其它光介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线418相连。存储装置428可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本发明各实施例的功能。Storage 428 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 430 and/or cache memory 432 . Server 412 may further include other removable/non-removable, volatile/non-volatile computer system storage media. For example only, storage system 434 may be used to read and write to non-removable, non-volatile magnetic media (not shown in FIG. 4, commonly referred to as a "hard drive"). Although not shown in Figure 4, a magnetic disk drive may be provided for reading and writing to removable non-volatile magnetic disks (eg "floppy disks"), as well as removable non-volatile optical disks such as Compact Disc Read -Only Memory, CD-ROM), digital video disc (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media) CD-ROM drive for reading and writing. In these cases, each drive may be connected to bus 418 through one or more data media interfaces. Storage 428 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of various embodiments of the present invention.
具有一组(至少一个)程序模块442的程序/实用工具440,可以存储在例如存储装置428中,这样的程序模块442包括但不限于操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块442通常执行本发明所描述的实施例中的功能和/或方法。A program/utility 440 having a set (at least one) of program modules 442, which may be stored, for example, in storage device 428, such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and programs Data, each or some combination of these examples may include an implementation of a network environment. Program modules 442 generally perform the functions and/or methods of the described embodiments of the present invention.
服务器412也可以与一个或多个外部设备414(例如键盘、指向服务器、显示器424等)通信,还可与一个或者多个使得用户能与该服务器412交互的服务器通信,和/或与使得该服务器412能与一个或多个其它计算服务器进行通信的任何服务器(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口422进行。并且,服务器412还可以通过网络适配器420与一个或者多个网络(例如局域网(Local Area Network,LAN),广域网(Wide Area Network,WAN)和/或公共网络,例如因特网)通信。如图4所示,网络适配器420通过总线418与服务器412的其它模块通信。应当明白,尽管图中未示出,可以结合服务器412使用其它硬件和/或软件模块,包括但不限于:微代码、服务器驱动器、冗余处理器、外部磁盘驱动阵列、磁盘阵列(Redundant Arrays of Independent Disks,RAID)系统、磁带驱动器以及数据备份存储系统等。The server 412 may also communicate with one or more external devices 414 (eg, keyboards, pointing servers, display 424, etc.), with one or more servers that enable a user to interact with the server 412, and/or with the Server 412 can communicate with any server (eg, network card, modem, etc.) that communicates with one or more other computing servers. Such communication may take place through input/output (I/O) interface 422 . Also, the server 412 may communicate with one or more networks (eg, Local Area Network (LAN), Wide Area Network (WAN), and/or public networks such as the Internet) through a network adapter 420 . As shown in FIG. 4 , network adapter 420 communicates with other modules of server 412 via bus 418 . It should be understood that, although not shown, other hardware and/or software modules may be used in conjunction with server 412, including but not limited to: microcode, server drivers, redundant processors, external disk drive arrays, Redundant Arrays of disks Independent Disks, RAID) systems, tape drives and data backup storage systems.
处理器416通过运行存储在存储装置428中的程序,从而执行各种功能应用以及数据处理,例如实现本发明任意实施例所提供的线程任务处理方法,该方法可以包括:The processor 416 executes various functional applications and data processing by running the programs stored in the storage device 428, for example, to implement the thread task processing method provided by any embodiment of the present invention, and the method may include:
获取任务队列,所述任务队列包括多个第一任务;obtaining a task queue, the task queue includes a plurality of first tasks;
判断所述第一任务是否被分配对应的线程池;judging whether the first task is assigned a corresponding thread pool;
若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数;If the first task is not assigned a corresponding thread pool, obtain the thread pool configuration parameters of the first task;
根据所述配置参数配置线程池,所述线程池包括多个第一线程;Configure a thread pool according to the configuration parameter, and the thread pool includes a plurality of first threads;
调用所述第一线程执行所述第一任务,并记录对应的执行结果。The first thread is called to execute the first task, and the corresponding execution result is recorded.
实施例五Embodiment 5
本发明实施例五还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如本发明任意实施例所提供的线程任务处理方法,该方法可以包括:Embodiment 5 of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, implements the thread task processing method provided by any embodiment of the present invention, and the method may include:
获取任务队列,所述任务队列包括多个第一任务;obtaining a task queue, the task queue includes a plurality of first tasks;
判断所述第一任务是否被分配对应的线程池;judging whether the first task is assigned a corresponding thread pool;
若所述第一任务没被分配对应的线程池,获取所述第一任务的线程池配置参数;If the first task is not assigned a corresponding thread pool, obtain the thread pool configuration parameters of the first task;
根据所述配置参数配置线程池,所述线程池包括多个第一线程;Configure a thread pool according to the configuration parameter, and the thread pool includes a plurality of first threads;
调用所述第一线程执行所述第一任务,并记录对应的执行结果。The first thread is called to execute the first task, and the corresponding execution result is recorded.
本发明实施例的计算机存储介质,可以采用一个或多个计算机可读的介质的任意组合。计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本文件中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。The computer storage medium in the embodiments of the present invention may adopt any combination of one or more computer-readable mediums. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples (a non-exhaustive list) of computer readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A computer-readable signal medium may include a propagated data signal in baseband or as part of a carrier wave, with computer-readable program code embodied thereon. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .
计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括——但不限于无线、电线、光缆、RF等等,或者上述的任意合适的组合。Program code embodied on a computer readable medium may be transmitted using any suitable medium, including - but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
可以以一种或多种程序设计语言或其组合来编写用于执行本发明操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including object-oriented programming languages—such as Java, Smalltalk, C++, but also conventional Procedural programming language - such as the "C" language or similar programming language. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (eg, using an Internet service provider through Internet connection).
注意,上述仅为本发明的较佳实施例及所运用技术原理。本领域技术人员会理解,本发明不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本发明的保护范围。因此,虽然通过以上实施例对本发明进行了较为详细的说明,但是本发明不仅仅限于以上实施例,在不脱离本发明构思的情况下,还可以包括更多其他等效实施例,而本发明的范围由所附的权利要求范围决定。Note that the above are only preferred embodiments of the present invention and applied technical principles. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and can also include more other equivalent embodiments without departing from the concept of the present invention. The scope is determined by the scope of the appended claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910671537.3A CN110413390A (en) | 2019-07-24 | 2019-07-24 | Thread task processing method, device, server and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910671537.3A CN110413390A (en) | 2019-07-24 | 2019-07-24 | Thread task processing method, device, server and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110413390A true CN110413390A (en) | 2019-11-05 |
Family
ID=68362848
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910671537.3A Pending CN110413390A (en) | 2019-07-24 | 2019-07-24 | Thread task processing method, device, server and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110413390A (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111078371A (en) * | 2019-11-14 | 2020-04-28 | 泰康保险集团股份有限公司 | Branch task reconstruction method and device based on Flowable flow engine |
CN111159236A (en) * | 2019-12-23 | 2020-05-15 | 五八有限公司 | Data processing method and device, electronic equipment and storage medium |
CN111176806A (en) * | 2019-12-05 | 2020-05-19 | 中国银联股份有限公司 | Service processing method, device and computer readable storage medium |
CN111343152A (en) * | 2020-02-07 | 2020-06-26 | 北京达佳互联信息技术有限公司 | Data processing method and device, electronic equipment and storage medium |
CN111625329A (en) * | 2020-05-18 | 2020-09-04 | 北京达佳互联信息技术有限公司 | Task allocation method and device, electronic equipment, server and storage medium |
CN111625270A (en) * | 2020-05-21 | 2020-09-04 | 浪潮电子信息产业股份有限公司 | Development environment creating method, device, equipment and storage medium |
CN111913804A (en) * | 2020-07-30 | 2020-11-10 | 平安证券股份有限公司 | Pre-visit report generation method and device, electronic equipment and storage medium |
CN113031870A (en) * | 2021-03-26 | 2021-06-25 | 山东英信计算机技术有限公司 | Dynamic management method, device, storage medium and equipment for cluster system |
CN114385227A (en) * | 2022-01-17 | 2022-04-22 | 中国农业银行股份有限公司 | A business processing method, device, equipment and storage medium |
CN114598664A (en) * | 2020-12-03 | 2022-06-07 | 武汉斗鱼鱼乐网络科技有限公司 | A task execution method and related device |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101777008A (en) * | 2009-12-31 | 2010-07-14 | 中兴通讯股份有限公司 | Method and device for realizing mobile terminal system thread pool |
US20120297393A1 (en) * | 2009-12-30 | 2012-11-22 | Zte Corporation | Data Collecting Method, Data Collecting Apparatus and Network Management Device |
CN105159768A (en) * | 2015-09-09 | 2015-12-16 | 浪潮集团有限公司 | Task management method and cloud data center management platform |
CN106899649A (en) * | 2016-06-30 | 2017-06-27 | 阿里巴巴集团控股有限公司 | A kind of task requests processing method, device and user equipment |
CN107391243A (en) * | 2017-06-30 | 2017-11-24 | 广东神马搜索科技有限公司 | Thread task processing equipment, device and method |
CN107463439A (en) * | 2017-08-21 | 2017-12-12 | 山东浪潮通软信息科技有限公司 | A kind of thread pool implementation method and device |
CN108733461A (en) * | 2017-04-18 | 2018-11-02 | 北京京东尚科信息技术有限公司 | Distributed task dispatching method and apparatus |
CN109582684A (en) * | 2018-11-30 | 2019-04-05 | 深圳市盟天科技有限公司 | A kind of update method of local cache data, device, server and storage medium |
CN109582455A (en) * | 2018-12-03 | 2019-04-05 | 恒生电子股份有限公司 | Multithreading task processing method, device and storage medium |
CN109753354A (en) * | 2018-11-26 | 2019-05-14 | 平安科技(深圳)有限公司 | Processing method, device and the computer equipment of Streaming Media task based on multithreading |
CN109814994A (en) * | 2019-01-03 | 2019-05-28 | 福建天泉教育科技有限公司 | A kind of method and terminal of dynamic dispatching thread pool |
CN109992414A (en) * | 2019-03-12 | 2019-07-09 | 平安普惠企业管理有限公司 | A thread pool-based task processing method and device |
-
2019
- 2019-07-24 CN CN201910671537.3A patent/CN110413390A/en active Pending
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120297393A1 (en) * | 2009-12-30 | 2012-11-22 | Zte Corporation | Data Collecting Method, Data Collecting Apparatus and Network Management Device |
CN101777008A (en) * | 2009-12-31 | 2010-07-14 | 中兴通讯股份有限公司 | Method and device for realizing mobile terminal system thread pool |
CN105159768A (en) * | 2015-09-09 | 2015-12-16 | 浪潮集团有限公司 | Task management method and cloud data center management platform |
CN106899649A (en) * | 2016-06-30 | 2017-06-27 | 阿里巴巴集团控股有限公司 | A kind of task requests processing method, device and user equipment |
CN108733461A (en) * | 2017-04-18 | 2018-11-02 | 北京京东尚科信息技术有限公司 | Distributed task dispatching method and apparatus |
CN107391243A (en) * | 2017-06-30 | 2017-11-24 | 广东神马搜索科技有限公司 | Thread task processing equipment, device and method |
CN107463439A (en) * | 2017-08-21 | 2017-12-12 | 山东浪潮通软信息科技有限公司 | A kind of thread pool implementation method and device |
CN109753354A (en) * | 2018-11-26 | 2019-05-14 | 平安科技(深圳)有限公司 | Processing method, device and the computer equipment of Streaming Media task based on multithreading |
CN109582684A (en) * | 2018-11-30 | 2019-04-05 | 深圳市盟天科技有限公司 | A kind of update method of local cache data, device, server and storage medium |
CN109582455A (en) * | 2018-12-03 | 2019-04-05 | 恒生电子股份有限公司 | Multithreading task processing method, device and storage medium |
CN109814994A (en) * | 2019-01-03 | 2019-05-28 | 福建天泉教育科技有限公司 | A kind of method and terminal of dynamic dispatching thread pool |
CN109992414A (en) * | 2019-03-12 | 2019-07-09 | 平安普惠企业管理有限公司 | A thread pool-based task processing method and device |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111078371A (en) * | 2019-11-14 | 2020-04-28 | 泰康保险集团股份有限公司 | Branch task reconstruction method and device based on Flowable flow engine |
CN111078371B (en) * | 2019-11-14 | 2023-04-18 | 泰康保险集团股份有限公司 | Branch task reconstruction method and device based on Flowable process engine |
CN111176806A (en) * | 2019-12-05 | 2020-05-19 | 中国银联股份有限公司 | Service processing method, device and computer readable storage medium |
CN111176806B (en) * | 2019-12-05 | 2024-02-23 | 中国银联股份有限公司 | Service processing method and device and computer readable storage medium |
CN111159236A (en) * | 2019-12-23 | 2020-05-15 | 五八有限公司 | Data processing method and device, electronic equipment and storage medium |
CN111343152A (en) * | 2020-02-07 | 2020-06-26 | 北京达佳互联信息技术有限公司 | Data processing method and device, electronic equipment and storage medium |
CN111625329A (en) * | 2020-05-18 | 2020-09-04 | 北京达佳互联信息技术有限公司 | Task allocation method and device, electronic equipment, server and storage medium |
CN111625270A (en) * | 2020-05-21 | 2020-09-04 | 浪潮电子信息产业股份有限公司 | Development environment creating method, device, equipment and storage medium |
CN111913804A (en) * | 2020-07-30 | 2020-11-10 | 平安证券股份有限公司 | Pre-visit report generation method and device, electronic equipment and storage medium |
CN114598664A (en) * | 2020-12-03 | 2022-06-07 | 武汉斗鱼鱼乐网络科技有限公司 | A task execution method and related device |
CN113031870A (en) * | 2021-03-26 | 2021-06-25 | 山东英信计算机技术有限公司 | Dynamic management method, device, storage medium and equipment for cluster system |
CN114385227A (en) * | 2022-01-17 | 2022-04-22 | 中国农业银行股份有限公司 | A business processing method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110413390A (en) | Thread task processing method, device, server and storage medium | |
US8918673B1 (en) | Systems and methods for proactively evaluating failover nodes prior to the occurrence of failover events | |
CN112668386A (en) | Long running workflows for document processing using robotic process automation | |
US8572613B1 (en) | Comparison of virtual computing states by performing identified repeatable computations in a changing virtual computing environment | |
US8347288B1 (en) | System and method for verification of repeatable virtualized computing | |
TWI533213B (en) | Storing and resuming application runtime state | |
US11157373B2 (en) | Prioritized transfer of failure event log data | |
US8495573B2 (en) | Checkpoint and restartable applications and system services | |
JP2020091835A (en) | Method and device for processing information | |
US7962782B2 (en) | Modifying connection records | |
US8904063B1 (en) | Ordered kernel queue for multipathing events | |
US10514972B2 (en) | Embedding forensic and triage data in memory dumps | |
US9448912B2 (en) | Providing service address space for diagnostics collection | |
WO2014190806A1 (en) | Application backup and restore | |
US11720424B2 (en) | Single flow execution | |
US11868769B1 (en) | Automatically determining and modifying environments for running microservices in a performant and cost-effective manner | |
CN111930502A (en) | Server management method, device, equipment and storage medium | |
US20150106661A1 (en) | Device State Capture During Operating System Dump | |
CN114546269A (en) | Storage mounting method and device and electronic equipment | |
CN115129536A (en) | Dynamic monitoring | |
JP5884566B2 (en) | Batch processing system, progress confirmation device, progress confirmation method, and program | |
WO2021135326A1 (en) | Data backup method, apparatus and device, and medium | |
US9292396B2 (en) | System and method for secure remote diagnostics | |
US8984336B1 (en) | Systems and methods for performing first failure data captures | |
CN110365839A (en) | Shutdown method, device, medium and electronic device |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20191105 |
|
RJ01 | Rejection of invention patent application after publication |