CN106681811A - Multi-thread scheduling method and device based on thread pool - Google Patents

Multi-thread scheduling method and device based on thread pool Download PDF

Info

Publication number
CN106681811A
CN106681811A CN201611122099.8A CN201611122099A CN106681811A CN 106681811 A CN106681811 A CN 106681811A CN 201611122099 A CN201611122099 A CN 201611122099A CN 106681811 A CN106681811 A CN 106681811A
Authority
CN
China
Prior art keywords
lock
task object
thread
countdown
goal task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201611122099.8A
Other languages
Chinese (zh)
Other versions
CN106681811B (en
Inventor
鲁可
黄闻欣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201611122099.8A priority Critical patent/CN106681811B/en
Publication of CN106681811A publication Critical patent/CN106681811A/en
Application granted granted Critical
Publication of CN106681811B publication Critical patent/CN106681811B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

The embodiment of the invention discloses a multi-thread scheduling method based on a thread pool. The method comprises the steps that a calling process of a thread scheduling function of the thread pool is detected, and stack characteristic information of a calling stack corresponding to the calling process and a target task object are obtained; an operation function of the target task object is detected and called, a counting lock and/or a countdown lock corresponding to the stack characteristics information are/is added to the operation function of the target task object, the locking state of the counting lock and/or the countdown lock is detected, the counting lock is released when the thread number corresponding to the target task object is larger than or equal to the threshold value of the counting lock, and the countdown lock is released after a preset period of time is waited; when the counting lock and/or the countdown lock are/is in the locked state, the execution of the operation function of the target task object is stopped. When the locked state of the counting lock or the countdown lock is released, the operation function of the target task object is executed. By adopting the multi-thread scheduling method, the program crash recurrence rate can be increased.

Description

Multithread scheduling method and device based on thread pool
Technical field
The present invention relates to field of computer technology, more particularly to a kind of multithread scheduling method and dress based on thread pool Put.
Background technology
With the development of to-talk internet technology, various application programs are applied more and more extensively in user's life, and are used Requirement of the family to the performance of application program also more and more higher.Wherein, stability is to weigh the importance of an application program capacity Index, also, the stability of application program determines to a certain extent the retention ratio of application program and the quality of public praise, because This, lifts the stability of application program for the development of application program has highly important meaning.In the exploitation of application program During use, the program crashing (Crash) that can occur during operation for application program is analyzed and reappears, It is determined that the concrete reason of triggering Crash, and be modified based on the reason, to improve application program stablizing in running Property.
During debugging to application program, current function call stack can be checked;For example, in correlation technique In, function call stack when when there is program crashing (Crash) generating program can be reported to collapse, program development can basis The function call stack content for reporting is determining the reason for collapsing.But, because in existing terminal many Crash be by Fight for caused by resource in multithreading, and in android system, thread is entered by thread pool ThreadPoolExecutor It is not to directly invoke start methods during row scheduling and management, but opening for each thread is determined by thread pool The dynamic time, that is to say, that the startup opportunity of thread is determined by developer, with uncertainty, for example, thread can be subject to The impact of the correlative factors such as size, the thread cache queue in pond, which results in reproduction Crash during, developer without Method determines the specific starting time of each thread, it is impossible to each thread when Crash reported before reproduction occurs Specific starting time, it is impossible to which reduction specifically uses scene when program debugging or user are used, it is impossible to know triggering The true cause of Crash.
That is, in above-mentioned correlation technique, existing cannot be accurately positioned asking for generation Crash when there is Crash Topic.
The content of the invention
Based on this, what is existed when being the reason for finder solved in conventional art occurs collapse (Crash) generation answers Now the not enough technical problem of rate, special to propose a kind of multithread scheduling method based on thread pool.
A kind of multithread scheduling method based on thread pool, including:
The invoked procedure of the thread scheduling function of detection thread pool, obtains the heap of the corresponding allocating stack of the invoked procedure Stack characteristic information and goal task object, the goal task object is the object for realizing thread interface;
The operation function of the goal task object is called in detection, is added on the operation function of the goal task object Puzzle lock corresponding with the storehouse characteristic information and/or countdown are locked, and detect the locking of the Puzzle lock and/or countdown lock State, the Puzzle lock discharges in threshold value of the Thread Count corresponding with goal task object more than or equal to the Puzzle lock, The countdown is locked in after wait preset duration and discharges;
When the counting and/or countdown lock are in the lock state, suspend the operation for performing the goal task object Function;
When the lock-out state locked in the Puzzle lock or countdown discharges, the operation letter of the goal task object is performed Number.
Optionally, wherein in one embodiment, the storehouse for obtaining the corresponding allocating stack of the invoked procedure is special Reference ceases and goal task object includes:The storehouse that the thread scheduling function call of the thread pool is obtained by Hook Function is special Reference ceases and goal task object.
Optionally, wherein in one embodiment, addition and the institute on the operation function of the goal task object Stating the corresponding Puzzle lock of storehouse characteristic information and/or countdown lock also includes:It is the goal task object by Hook Function Operation function add corresponding with stack information Puzzle lock or countdown lock.
Optionally, wherein in one embodiment, the detection calls the operation function of the goal task object also to wrap Include:
The goal task object is obtained by Hook Function corresponding with the operation function of the goal task object Class name;
Judge that whether the class name is the class name of default application to be measured, if so, then perform described in the goal task Add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on the operation function of object.
Optionally, wherein in one embodiment, the storehouse for obtaining the corresponding allocating stack of the invoked procedure is special Reference ceases and also includes after goal task object:The Hash codes of the goal task object are obtained, by the Hash codes and institute State the storage of storehouse characteristic information correspondence in the buffer;
It is described to add Puzzle lock corresponding with the storehouse characteristic information on the operation function of the goal task object And/or countdown lock also includes:Storehouse characteristic information corresponding with the Hash codes of the goal task object is searched, is obtained and institute State the corresponding Puzzle lock of storehouse characteristic information and/or countdown lock.
Optionally, wherein in one embodiment, methods described also includes:Lock in the Puzzle lock or the countdown After lock-out state release, by the Hash codes of the goal task object and the storehouse characteristic information of storage corresponding with the Hash codes Remove from the caching.
Additionally, the reproduction that the finder in solve conventional art exists when occurring the reason for collapse (Crash) occurs The not enough technical problem of rate, spy proposes a kind of multithread scheduling device based on thread pool.
A kind of multithread scheduling device based on thread pool, including:
Thread scheduling function call module, for detecting the invoked procedure of the thread scheduling function of thread pool, obtains described The storehouse characteristic information and goal task object of the corresponding allocating stack of invoked procedure, the goal task object is to realize line The object of journey interface;
Synchrolock add module, for the operation function that the goal task object is called in detection, in the goal task Add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on the operation function of object, detect the counting The lock-out state of lock and/or countdown lock, the Puzzle lock is more than or equal to institute in Thread Count corresponding with goal task object Discharge when stating the threshold value of Puzzle lock, the countdown is locked in after wait preset duration and discharges;
Suspend performing module, for when the counting and/or countdown lock are in the lock state, suspending and performing the mesh The operation function of mark task object;
Operation function performing module, when the lock-out state for locking in the Puzzle lock or countdown discharges, performs described The operation function of goal task object.
Optionally, wherein in one embodiment, the thread scheduling function call module is additionally operable to by Hook Function Obtain the storehouse characteristic information and goal task object of the thread scheduling function call of the thread pool.
Optionally, wherein in one embodiment, it is described that the synchrolock add module is additionally operable to by Hook Function The operation function of goal task object adds Puzzle lock corresponding with the stack information or countdown lock.
Optionally, wherein in one embodiment, the synchrolock add module be additionally operable to by with the goal task The corresponding Hook Function of operation function of object obtains the class name of the goal task object;Judge whether the class name is default Application to be measured class name, in the class name of the entitled default application to be measured of the class, perform and described appoint in the target Add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on the operation function of business object.
Optionally, wherein in one embodiment, described device also includes Hash codes correspondence memory module, for obtaining The Hash codes of goal task object are stated, by Hash codes storage corresponding with the storehouse characteristic information in the buffer;It is described same Step lock add module is additionally operable to search corresponding with the Hash codes of goal task object storehouse characteristic information, obtain with it is described The corresponding Puzzle lock of storehouse characteristic information and/or countdown are locked.
Optionally, wherein in one embodiment, described device also includes that Hash codes store remove module, for described Puzzle lock or the countdown lock lock-out state release after, by the Hash codes of the goal task object and with the Hash codes The storehouse characteristic information of correspondence storage is removed from the caching.
Implement the embodiment of the present invention, will have the advantages that:
After employing the above-mentioned multithread scheduling method and apparatus based on thread pool, thread scheduling is called in thread pool During function, the corresponding goal task object of thread scheduling function and allocating stack are called in acquisition, then call this detecting During the operation function of goal task object, obtain Puzzle lock corresponding with above-mentioned allocating stack and/or countdown is locked and will be counted On lock and/or the above-mentioned operation function for detecting of countdown lock addition, so that the thread for calling the operation function suspends execution, And the execution of above-mentioned thread can be same after the above-mentioned Puzzle lock being added on the operation function and/or countdown lock are released Step is performed, also, lock can suspend because of addition Puzzle lock when the thread request quantity of execution reaches threshold value release or Corresponding thread waiting time discharges when exceeding preset duration.That is, because the run methods of Runnable objects are locked And suspending the thread for performing can synchronously perform after the lock release, equivalent to the execution opportunity for controlling related linear program;This is just So that during reproduction Crash, because the thread of invocation target task object and corresponding allocating stack can be caused same Shi Zhihang, simulates the application scenarios that the multiple threads in actual use scene thread pool fight for resource simultaneously, relative to Can only be controlled by controlling the number of threads of thread pool for the scheme of the number of threads of execution simultaneously in correlation technique, be improved Because multiple threads fight for the probability that program crashing occurs again caused by resource simultaneously in actual use scene, so as to The probability of the caused system crash because multithreading fights for resource is improve, can more be accelerated in the program test for thus making Program crashing is found fastly and helps tester to analyze its reason, improve the efficiency of program test.
Description of the drawings
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing The accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are only this Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can be with Other accompanying drawings are obtained according to these accompanying drawings.
Wherein:
Fig. 1 is the thread scheduling process schematic of one embodiment thread pool;
Fig. 2 is a kind of schematic flow sheet of the multithread scheduling method based on thread pool in one embodiment;
Fig. 3 is a kind of schematic flow sheet of the multithread scheduling method based on thread pool in one embodiment;
Fig. 4 is a kind of structural representation of the multithread scheduling device based on thread pool in one embodiment;
Fig. 5 is the structure of the computer equipment that the aforementioned multithread scheduling method based on thread pool is run in one embodiment Schematic diagram.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than the embodiment of whole.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of protection of the invention.
The recurrence rate existed during the reason for finder generating program collapse (Crash) in solve conventional art occurs Not enough technical problem, in the present embodiment, spy proposes a kind of multithread scheduling method based on thread pool, the reality of the method Computer program is now can be dependent on, the computer program can run on the computer system based on von Neumann system, should Computer program can be the thread scheduler in application and development test process.The computer system can be the above-mentioned meter of operation Server or the terminals such as such as smart mobile phone, panel computer, the PC of calculation machine program.
In the present embodiment, program crashing (Crash) is referred to during computer system pressure or performance test, because There is the machine of delaying for certain reason, or the work of main frame, program stopped, situations such as stop response, process interrupt, such as program crashing. And in multithreading running environment, due to uncertainty during thread contention access resource, therefore be easier to cause program to occur Collapse.There is Crash in the operation of the exploitation test Program of application program, can by the Crash and when there is Crash it is current The related data such as function call storehouse report corresponding platform or server, or, use the application program in user When there is Crash and also the related data such as the Crash and current function call storehouse when there is Crash can be reported accordingly Platform or server, corresponding Crash is analyzed by the platform or server, lay equal stress on kainogenesis Crash when make With scene, so that it is determined that triggering the true cause of Crash, and debugged and corrected for the reason.
In the present embodiment, following multithread scheduling methods based on thread pool be exactly in order to realize user using or open The concrete scene and the developer after there is Crash for sending out thread scheduling of the personnel during program debugging should in reproduction The concrete scene of the thread scheduling during application scenarios that Crash occurs is consistent, that is to say, that improve the general of reproduction Crash Rate.
It should be noted that in the present embodiment, the above-mentioned multithread scheduling method based on thread pool can be based on Android The terminal of system, also, in the terminal, the processing procedure of thread is completed by thread pool, for example, The thread pool ThreadPoolExecutor carried in android system, i.e. the startup of all of thread is to pass through ThreadPoolExecutor.execute (Runnable examples) is incoming, and wherein Runnable examples are to realize that Runnable connects The object of mouth, thread pool can carry out Collective stewardship and scheduling to thread therein, and user can be with the setting thread of automatic or manual The size of pond thread quantity, with the number of threads for controlling to run, so as to avoid, system is crowded or waste of system resource.
For example, in the schematic diagram of the thread scheduling of the thread pool shown in Fig. 1, task object is created by What ThreadPoolExecutor.execute (Runnable examples) was realized, then by the corresponding task of Runnable examples In being added to thread pool;During the corresponding task of Runnable examples is added to into thread pool, by thread pool according to CorePoolSize (i.e. thread pool safeguards the minimum number of thread) corresponding with the thread pool, buffer queue and MaximumPoolSize (i.e. thread pool safeguards the maximum quantity of thread) is determining the implementation strategy of the task.Specifically, if Quantity in thread pool is less than corePoolSize, creates new thread to process being added for task;If in thread pool Quantity be more than or equal to corePoolSize, but buffer queue less than, then task is placed into buffer queue;If thread pool In quantity be more than corePoolSize, buffer queue is full, and the quantity in thread pool is less than maximumPoolSize, wound Build new thread to process being added for task;If the quantity in thread pool is more than corePoolSize, buffer queue is full, and And the quantity in thread pool is equal to maximumPoolSize, then by handler (process plans of the thread pool to refusal task Strategy specified by slightly) is processing this task.That is, the concrete execution opportunity for being added to the thread of thread pool be not by with Family is scheduled according to the number of threads that there is currently in thread pool controlling by thread pool.
It should be noted that the execution of said method may also rely on other User Defineds are write or third party The thread pool component that development teams are write, and the execution of said method is also not necessarily limited to android system, also apply be applicable to ios, Windows etc. other has in the operating system of threading mechanism.
Specifically, as shown in Fig. 2 the above-mentioned multithread scheduling method based on thread pool comprises the steps S102-S108:
Step S102:The invoked procedure of the thread scheduling function of detection thread pool, obtains the corresponding tune of the invoked procedure With the storehouse characteristic information and goal task object of storehouse, the goal task object is the object for realizing thread interface.
Under the multi-thread environment of thread pool, when there is new task to need to process, then the thread for calling thread pool is needed The need new task to be processed is added in thread pool and is scheduled by thread pool by scheduling function.In the present embodiment, Under the thread pool ThreadPoolExecutor of android system, thread scheduling function is system class The execute methods of ThreadPoolExecutor, i.e. ThreadPoolExecutor.execute;That is, thread is adjusted Degree function refers to that the task object of such as Runnable examples is added in thread pool further to be adjusted by thread pool The function of degree, also, this is this by the new task or task object that the thread scheduling function of thread pool be added to thread pool Goal task object corresponding to the thread scheduling function of thread pool.
In the present embodiment, when the thread scheduling function for detecting thread pool is called, obtain and calling the thread to adjust Corresponding allocating stack during degree function, also, also obtain the image parameter of the invoked procedure thread scheduling function, i.e. target times Business object (i.e. by the incoming Runnable examples of the execute methods).In the present embodiment, above-mentioned goal task object is Realize the task object of Runnable thread interfaces, i.e. Runnable examples.One Runnable example can be by inheriting Thread classes or ThreadPoolExecutor classes generate multiple tasks object.
Specifically, when the execute methods of ThreadPoolExecutor are called, specific form is ThreadPoolExecutor.execute (Runnable examples), that is, be according to the realizing Runnable interfaces of the task The run methods of the corresponding task object asynchronous execution Runnable examples of Object Creation one.When repeatedly calling During ThreadPoolExecutor.execute (Runnable examples), then creating multiple tasks object asynchronous execution should The run methods of Runnable examples;And the storehouse characteristic information of the plurality of task object is identical.
It should be noted that in the present embodiment, it is right in the task object that the storehouse characteristic information of allocating stack is referred to The characteristic information corresponding to storehouse that the function calling relationship answered takes in internal memory, also, this feature information can be sequence The sequence code of change, the storehouse characteristic information for the current allocating stack of unique mark, also, different allocating stacks is different , corresponding allocating stack can be uniquely determined according to storehouse characteristic information.That is, in follow-up operation, being added on It is exactly according to heap during Puzzle lock corresponding with storehouse characteristic information and/or countdown are locked on the operation function of goal task object Stack characteristic information is distinguishing different allocating stacks and different Puzzle locks and/or countdown lock.
Further, in the present embodiment, the invoked procedure of the thread scheduling function of above-mentioned detection thread pool and acquisition During the storehouse characteristic information and goal task object of the corresponding allocating stack of the invoked procedure, it is possible to use hook letter The acquisition of storehouse characteristic information and goal task object in counting to realize the monitoring to thread scheduling function and invoked procedure, Specifically, the storehouse characteristic information and goal task object for obtaining the corresponding allocating stack of the invoked procedure includes:It is logical Cross the storehouse characteristic information and goal task object of the thread scheduling function call of the Hook Function acquisition thread pool.
Hook Function (hook) is a platform of system message treatment mechanism, and application program can arrange sub- journey above Sequence to monitor the behavior act of specified function, and the specified function for being monitored can other threads created, performing Process and can first process before the specified function thread information.In addition, Hook mechanism allows application program to intercept and capture processes Window Message or particular event, hook is actually the program segment of a process message, is called by system, Hook functions are linked into are System, before unloading keyboard layout is performed, Hook functions just first capture thread information, and then Hook functions can be somebody's turn to do with processed Thread information, it is also possible to do not deal with and continue to transmit the thread information, the transmission for terminating the thread information can also be forced.
In being embodied as, hook certain function is exactly operationally to add before the execution of this function or after performing Executable code, when operationally performing the function, similarly performs the executable code of these additions.For example, in this enforcement In example, the storehouse characteristic information and goal task pair of the thread scheduling function call of the thread pool are obtained by Hook Function As the storehouse of the thread scheduling function call for obtaining the thread pool is realized in the addition as before the execution of the thread scheduling function The executable code of characteristic information and goal task object functionality.
In being embodied as, in advance addition hook obtains the thread tune of the thread pool before corresponding thread scheduling function The storehouse characteristic information of the function call executable code related to goal task object is spent, so as to call the line of thread pool It is special by the storehouse for performing the thread scheduling function call that above-mentioned advance addition hook obtains the thread pool during journey scheduling function Reference cease and goal task object correlative code come obtain thread pool thread scheduling function call storehouse characteristic information and Goal task object.
Optionally, can also carry out whether hook calls phase with monitoring thread pond to the thread scheduling function of above-mentioned thread pool The thread scheduling function answered is added to new task object in thread pool.It should be noted that in the present embodiment, this is new Task object can be existing task object, be added in thread pool by thread scheduling function;Can also be new establishment Task object, that is, create new task object and the new task object be added in thread pool and managed by thread pool Reason.Specifically, the correlative code that hook is carried out to thread scheduling function was added before thread scheduling function, thread pool is occurring When calling of thread scheduling function, the correlative code of hook is carried out to thread scheduling function spreading goods phase by perform addition The thread scheduling information of pass.
Step S104:The operation function of the goal task object is called in detection, in the operation of the goal task object Add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on function, detect the Puzzle lock and/or count When the lock-out state locked, the Puzzle lock Thread Count corresponding with goal task object more than or equal to the Puzzle lock threshold Discharge during value, the countdown is locked in after wait preset duration and discharges.
Step S106:When the counting and/or countdown lock are in the lock state, suspend and perform the goal task pair The operation function of elephant.
Step S108:When the lock-out state locked in the Puzzle lock or countdown discharges, the goal task object is performed Operation function.
In the present embodiment, in invocation target task object Runnable examples, can be by calling operation function run Method is realizing.Generally, after the run methods of some Runnable example are have invoked in thread pool, should The corresponding thread of run methods of Runnable examples can be entered in thread pool is managed concentratedly, for example, in thread pool When number of threads is less than the corePoolSize of the thread pool, the thread is directly performed, the number of threads in thread pool is more than Or equal to the thread pool corePoolSize when, the thread can be added in corresponding buffer queue waiting of ranking.
In the present embodiment, in order to the operation function run methods for controlling the goal task object Runnable examples are corresponding Thread the execution time, can add before the run methods corresponding Puzzle lock or countdown lock, be added on the run In the case that Puzzle lock or countdown lock before method is locked, this calls the thread of the run methods of Runnable examples Execution can be suspended or stop to perform, until the lock-out state of the Puzzle lock being added on before the run methods or countdown lock is released Just may proceed to perform after putting.
It should be noted that in the present embodiment, the Puzzle lock being added on the corresponding operation function of invocation target thread Or countdown lock is that storehouse characteristic information corresponding with the goal task object Runnable examples is corresponding, that is to say, that Storehouse characteristic information corresponding with the invoked procedure of the thread scheduling function of step S102 thread pool is corresponding.Identical The lock added in the corresponding operation function run methods of subject thread corresponding to storehouse characteristic information is identical, also, When the lock is released, the thread added corresponding to the operation function run methods of same lock can be while enter into corresponding thread In configuration processor.
Specifically, the Puzzle lock being added in the operation function run methods of invocation target task object Runnable examples Threshold value corresponding with the Puzzle lock is further comprises, the threshold value is right for limiting the operation function run methods for adding Puzzle lock institute The maximum thread amount answered, that is to say, that in the corresponding operation letter run side operators of invocation target thread that with the addition of the Puzzle lock When corresponding number of threads exceedes above-mentioned threshold value, the Puzzle lock is released.
When the run methods of the Runnable examples are repeatedly called, call every time once, a line will be increased Journey, and this thread will be suspended to the calling for run methods of the Runnable examples due to the locking of Puzzle lock, but meeting Increase the counting of Puzzle lock, when the counting of Puzzle lock meets or exceeds threshold value, then by the lock release.
For example, the corresponding threshold value of the Puzzle lock is 5, then illustrate that the maximum thread amount corresponding to the Puzzle lock is 5, in companion As application to be measured calls the number of times of run methods to increase for same Runnable examples so that the counting in Puzzle lock also with Increase, when corresponding to the Puzzle lock when calling the number of threads of run methods of same Runnable examples to reach 5, the meter Number lock is released.That is, the thread for being suspended or stopping to perform will synchronously be performed after Puzzle lock release, so as to mould Draw up the application scenarios that 5 thread synchronizations are performed.
Further, also carry to be fallen with this in the countdown lock being added in the run methods for calling Runnable examples Corresponding preset duration is locked in timing, the preset duration be used for limiting by changed countdown lock suspend or stops execution thread most Long waiting time, also, the waiting time be from add being suspended earliest corresponding to the run methods of countdown lock or in The waiting time corresponding to thread for only performing.In the run methods pair for calling Runnable examples for being added to countdown lock When the waiting time answered exceedes the preset duration, the countdown lock is released.
It should be noted that in the present embodiment, the Puzzle lock that is added in the run methods for calling Runnable examples and Countdown lock can be while acting in the run methods of Runnable examples, also, in concrete implementation procedure, a need The release conditions for wanting one of lock are satisfied, that is, perform the corresponding thread of corresponding run methods.In the present embodiment, can be with Puzzle lock and countdown lock are referred to as into synchrolock, the synchrolock can be possessed the lock of tally function, or possess down The lock of clocking capability, can also be and be provided simultaneously with counting the lock with countdown function.Possess counting and countdown function at the same time When, the Thread Count for being suspended execution can be avoided to exceed certain quantity, make in the implementation procedure after follow-up lock is released Into congestion, it is also possible to avoid invocation target task object or allocating stack number of threads do not reach enumerator threshold value cause lock Delay the phenomenon being released.In concrete operations, it is only necessary to meet counting or a release conditions in countdown function I.e. releasable corresponding synchrolock, that is, only need to meet thread request quantity corresponding with the synchrolock more than default threshold value with And the waiting time of the synchrolock exceedes a condition in default duration the two release conditions, corresponding synchrolock is quilt Release, because the synchrolock is suspended or continues executing with by stopping the thread of execution.
In being embodied as, the above-mentioned Puzzle lock being added on the operation function of invocation target task object or countdown are locked Can be realized by hook, it is specifically, described to add on the operation function of the goal task object and the storehouse feature Also include before the corresponding Puzzle lock of information and/or countdown lock:By the operation that Hook Function is the goal task object Function adds Puzzle lock corresponding with the stack information or countdown lock.
Added before the operation function run methods by hook and lock corresponding related generation to Puzzle lock and/or countdown Code, so as to lock plus Puzzle lock and/or countdown before the run methods, also, follow-up when calling the run methods, leads to Cross the Puzzle lock and countdown locks to control the execution time of corresponding thread.
It should be noted that in another embodiment, be added on the operation function of the goal task object with What the corresponding Puzzle lock of the storehouse characteristic information and/or countdown lock can also add in advance, that is to say, that in advance corresponding Corresponding Puzzle lock or countdown lock are with the addition of on operation function, also, in step S104, is performed by hook corresponding Addition Puzzle lock or countdown lock code.
Specifically, add corresponding with the storehouse characteristic information on the operation function of the goal task object above-mentioned Puzzle lock and/or countdown lock and by the addition of operation function that Hook Function is the goal task object and the heap In the step of corresponding Puzzle lock of stack information or countdown are locked, if accordingly operation function did not added counting before this Lock and/or countdown lock, then perform above by the addition of operation function that Hook Function is the goal task object with it is described The step of corresponding Puzzle lock of stack information or countdown are locked;If third the operation function front added and storehouse characteristic information Corresponding Puzzle lock and/or countdown are locked, then need not again add lock, are directly performed above-mentioned in the goal task object Add Puzzle lock corresponding with the storehouse characteristic information on operation function and/or the step of countdown is locked.
Further, in the present embodiment, be not thread pool thread scheduling function corresponding to all of target appoint The operation function of business object can be added Puzzle lock or countdown lock, in addition it is also necessary to the goal task object that judgement is called accordingly Whether scope to be measured is preset, for example, if belong within the scope of application to be measured.
Specifically, the detection calls the operation function of the goal task object also to include:By appointing with the target The corresponding Hook Function of operation function of business object obtains the class name of the goal task object;Judge whether the class name is pre- If application to be measured class name, if so, then perform described in add on the operation function of the goal task object and the heap The corresponding Puzzle lock of stack characteristic information and/or countdown are locked.
That is, when the run methods of Runnable examples are called in detection, also obtaining the Runnable examples corresponding Class name, and judge that whether the class name is the class name of default application to be measured, also, only such it is entitled it is default it is to be measured should During class name, just add corresponding with the storehouse characteristic information on the run functions of the Runnable examples described in execution Puzzle lock and/or countdown the step of lock, that is to say, that if the Runnable that some the run method for detecting is called Class corresponding to example is not belonging to the class of default application to be measured, then need not perform the step of adding lock to the run methods, directly Connect the corresponding thread of execution.The task object that this is allowed for not in limit of consideration or not within test scope is corresponding Thread can be managed by thread pool and be dispatched, it is not necessary to carry out execution opportunity to it using Puzzle lock or countdown lock Limit.
As it was previously stated, in the present embodiment, it is root during to running function addition Puzzle lock or countdown lock The target person object Runnable examples that called according to the operation function run methods are corresponding in thread scheduling function to be called The storehouse characteristic information of storehouse is determining, that is to say, that goal task object Runnable examples, storehouse characteristic information and It is corresponding between Puzzle lock or countdown lock.In the present embodiment, in order to avoid the counting added during locking Lock or countdown lock are other allocating stacks, so as to affect the ideal effect in follow-up thread scheduling, to run side Before method is locked, in addition it is also necessary to it is determined that lock corresponding with the run methods, that is, determine the storehouse characteristic information institute of corresponding allocating stack Corresponding lock.
Specifically, the storehouse characteristic information and goal task object for obtaining the corresponding allocating stack of the invoked procedure Also include afterwards:The Hash codes of the goal task object are obtained, is deposited the Hash codes are corresponding with the storehouse characteristic information Storage is in the buffer;It is described to add counting corresponding with the storehouse characteristic information on the operation function of the goal task object Lock and/or countdown lock also include:Search corresponding with the Hash codes of goal task object storehouse characteristic information, obtain with The corresponding Puzzle lock of the storehouse characteristic information and/or countdown lock.
In the invoked procedure of the thread scheduling function of thread pool, the corresponding storehouse feature letter of the invoked procedure is being determined After the goal task object for ceasing and being called, in addition it is also necessary to obtain Hash codes hashcode of the Runnable examples, also, The corresponding relation set up between the hashcode of the Runnable examples and the storehouse characteristic information of the allocating stack, then should Corresponding relation between the hashcode of Runnable examples and the storehouse characteristic information of the allocating stack is stored in the buffer. In follow-up flow process, can by search the storehouse characteristic information of storage corresponding with current Runnable examples in the buffer come It is determined that allocating stack corresponding with the Runnable example e.
It should be noted that in the above-mentioned mistake by Hash codes and the storage of corresponding storehouse characteristic information correspondence in the buffer Journey can be stored in the storehouse characteristic information correspondence of the hashcode of Runnable examples and corresponding allocating stack to reflect In penetrating object container (i.e. map), for example, in one embodiment, said process can be passed through ExecutorAppLineAndClasshashCodeMap (hashcode, storehouse feature) is set up in mapping object container The mapping relations of the storehouse characteristic information of the hashcode of Runnable examples and corresponding allocating stack, it is known some During the hashcode of Runnable examples, can pass through to search mapping object container determination and the Runnable examples The corresponding storehouse characteristic informations of hashcode, then need to be added on the Runnable realities according to the storehouse characteristic information to determine Puzzle lock or countdown lock in the run methods of example.
Further, after the storage corresponding with storehouse characteristic information by the hashcode of Runnable examples, in institute State the mistake for adding Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on the run functions of Runnable examples Cheng Zhong, searches storehouse characteristic information corresponding with the hashcode of the Runnable examples in the memory area of correspondence storage, Then corresponding Puzzle lock and/or countdown lock are determined by the storehouse characteristic information.
In another optional embodiment, in the storehouse characteristic information for obtaining the corresponding allocating stack of the invoked procedure It is above-mentioned before the step of operation function of the goal task object is called in detection after the step of goal task object Method also includes:The class name of the goal task object is obtained, the class name is determined in the class name of default application to be measured, then Perform the Hash codes for obtaining the goal task object, be stored in the Hash codes are corresponding with the storehouse characteristic information Step in caching.
Optionally, in one embodiment, by the Hash codes of goal task object and it is corresponding with the Hash codes storage The correspondence storage of storehouse characteristic information be in order to lock in follow-up addition Puzzle lock and countdown during it is determined that addition Lock, after the lock is released, the storehouse characteristic information of the Hash codes of goal task object and storage corresponding with the Hash codes Between corresponding relation no longer need, therefore, Puzzle lock or countdown lock be released after, goal task corresponding with the lock The Hash codes of object and the storehouse characteristic information of correspondence storage can be removed from the cache, to save cache resources.
Specifically, methods described also includes:After the lock-out state release that the Puzzle lock or the countdown are locked, by institute The storehouse characteristic information of the Hash codes and storage corresponding with the Hash codes of stating goal task object is removed from the caching.
That is, detect Puzzle lock or countdown lock be released after, from storage Hash codes hashcode with The data of related correspondence corresponding to the lock of release storage are deleted in the caching of the corresponding relation of storehouse characteristic information.
Optionally, in one embodiment, as shown in figure 3, Fig. 3 illustrates a kind of multithread scheduling side based on thread pool The schematic flow sheet of method, in the application scenarios shown in Fig. 3, the tune of the thread scheduling function of thread pool is detected by Hook Function With process, the corresponding allocating stack of the invoked procedure is then obtained, and include default application to be measured in the allocating stack During class name, the goal task object (Runnable examples) of above-mentioned invoked procedure and the Hash of the Runnable examples are obtained Code.Then by lift application to be measured row is called determining the corresponding storehouse characteristic information of allocating stack, and the storehouse is special The storage corresponding with above-mentioned Hash codes of reference breath is in the buffer.Further, the class name of the above-mentioned Runnable examples of acquisition, and When the class name belongs to the monitored object of Hook Function, the run side for calling above-mentioned Runnable examples is detected by Hook Function Method, and the Hash codes of the corresponding Runnable examples of run methods for detecting are obtained, cached according to the Hash codes for getting The Hash codes of middle storage and lookup storehouse characteristic information corresponding with the Hash codes in the corresponding relation of storehouse characteristic information, and make It is corresponding to suspend that the storehouse characteristic information found with this is locked (Puzzle lock and/or countdown are locked) to above-mentioned run methods Run methods execution;When Puzzle lock is detected or corresponding release conditions are locked in countdown, discharge this and lock and perform because upper State run methods.
Above-described embodiment is employed, when thread scheduling function is called in thread pool, thread scheduling function pair is called in acquisition The goal task object answered and allocating stack, if the class that allocating stack or destination object are located includes application correspondence to be measured Type, then when the operation function for calling the goal task object is detected, obtain corresponding with above-mentioned allocating stack counting Lock and/or countdown are locked and add Puzzle lock and/or countdown lock on the above-mentioned operation function for detecting, so that calling this The thread of operation function suspends execution, and the execution of above-mentioned thread can be in the above-mentioned Puzzle lock being added on the operation function And/or countdown lock is released synchronous execution afterwards, also, locks and can suspend the thread request of execution because of addition Puzzle lock Release or the release when corresponding thread waiting time preset duration is exceeded when quantity reaches threshold value.That is, because The thread that the run methods of Runnable objects are locked and suspend execution can synchronously be performed after the lock release, equivalent to control The execution opportunity of related linear program is made;This is allowed for during reproduction Crash, because invocation target task pair can be caused As simultaneously the thread with corresponding allocating stack is performed, multiple threads of the simulation in actual use scene thread pool are simultaneously The application scenarios of resource are fought for, can only be controlled while performing by controlling the number of threads of thread pool relative in correlation technique Number of threads scheme for, improve in actual use scene because multiple threads are while journey caused by fighting for resource The probability that sequence collapse occurs again, so as to improve the probability of the caused system crash because multithreading fights for resource, so Program crashing can be more quickly found in the program test for just making and helps tester to analyze its reason, improve program The efficiency of test.
Additionally, exist during the reason for finder generating program collapse (Crash) in solve conventional art occurs The not enough technical problem of recurrence rate, in one embodiment, as shown in Figure 4, it is also proposed that a kind of multithreading based on thread pool Dispatching device, including thread scheduling function call module 102, synchrolock add module 104, time-out performing module 106 and fortune Line function performing module 108, wherein:
Thread scheduling function call module 102, for detecting the invoked procedure of the thread scheduling function of thread pool, obtains institute The storehouse characteristic information and goal task object of the corresponding allocating stack of invoked procedure are stated, the goal task object is to realize The object of thread interface;
Synchrolock add module 104, for the operation function that the goal task object is called in detection, appoints in the target Add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on the operation function of business object, detect the meter The lock-out state of number lock and/or countdown lock, the Puzzle lock is more than or equal in Thread Count corresponding with goal task object Discharge during the threshold value of the Puzzle lock, the countdown is locked in after wait preset duration and discharges;
Suspend performing module 106, for when the counting and/or countdown lock are in the lock state, suspending and performing institute State the operation function of goal task object;
Operation function performing module 108, when the lock-out state for locking in the Puzzle lock or countdown discharges, performs institute State the operation function of goal task object.
Optionally, in one embodiment, the thread scheduling function call module 102 is additionally operable to obtain institute by hook State the storehouse characteristic information and goal task object of the thread scheduling function call of thread pool.
Optionally, in one embodiment, the synchrolock add module 104 is additionally operable to appoint for the target by hook The operation function of business object adds Puzzle lock corresponding with the stack information or countdown lock.
Optionally, in one embodiment, the synchrolock add module 104 be additionally operable to by with the goal task pair The corresponding hook of operation function of elephant obtains the class name of the goal task object;Judge whether the class name is default to be measured Using class name, in the class name of the entitled default application to be measured of the class, perform described in the goal task object Operation function on add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock.
Optionally, in one embodiment, as shown in figure 4, said apparatus also include Hash codes correspondence memory module 110, For obtaining the Hash codes of the goal task object, caching is stored in by the Hash codes are corresponding with the storehouse characteristic information In;The synchrolock add module 104 is additionally operable to search storehouse feature letter corresponding with the Hash codes of the goal task object Breath, obtains Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock.
Optionally, in one embodiment, as shown in figure 4, said apparatus also include that Hash codes store remove module 112, For after the lock-out state release that the Puzzle lock or the countdown are locked, by the Hash codes of the goal task object and The storehouse characteristic information of storage corresponding with the Hash codes is removed from the caching.
Implement the embodiment of the present invention, will have the advantages that:
After employing the above-mentioned multithread scheduling method and apparatus based on thread pool, thread scheduling is called in thread pool During function, the corresponding goal task object of thread scheduling function and allocating stack are called in acquisition, then call this detecting During the operation function of goal task object, obtain Puzzle lock corresponding with above-mentioned allocating stack and/or countdown is locked and will be counted On lock and/or the above-mentioned operation function for detecting of countdown lock addition, so that the thread for calling the operation function suspends execution, And the execution of above-mentioned thread can be same after the above-mentioned Puzzle lock being added on the operation function and/or countdown lock are released Step is performed, also, lock can suspend because of addition Puzzle lock when the thread request quantity of execution reaches threshold value release or Corresponding thread waiting time discharges when exceeding preset duration.That is, because the run methods of Runnable objects are locked And suspending the thread for performing can synchronously perform after the lock release, equivalent to the execution opportunity for controlling related linear program;This is just So that during reproduction Crash, because the thread of invocation target task object and corresponding allocating stack can be caused same Shi Zhihang, simulates the application scenarios that the multiple threads in actual use scene thread pool fight for resource simultaneously, relative to Can only be controlled by controlling the number of threads of thread pool for the scheme of the number of threads of execution simultaneously in correlation technique, be improved Because multiple threads fight for the probability that program crashing occurs again caused by resource simultaneously in actual use scene, so as to The probability of the caused system crash because multithreading fights for resource is improve, can more be accelerated in the program test for thus making Program crashing is found fastly and helps tester to analyze its reason, improve the efficiency of program test.
In one embodiment, as shown in figure 5, Fig. 5 illustrates a kind of above-mentioned multithread scheduling based on thread pool of operation The terminal of the computer system based on von Neumann system of method.The computer system can be smart mobile phone, panel computer, The terminal units such as palm PC, notebook computer or PC.Specifically, it may include the outside connected by system bus is defeated Incoming interface 1001, processor 1002, memorizer 1003 and output interface 1004.Wherein, outer input interface 1001 optionally may be used At least include network interface 10012.Memorizer 1003 may include external memory 10032 (such as hard disk, CD or floppy disk etc.) and Built-in storage 10034.Output interface 1004 can at least include the grade equipment of display screen 10042.
In the present embodiment, the operation of this method is based on computer program, and the program file of the computer program is stored in In the external memory 10032 of the aforementioned computer system based on von Neumann system, built-in storage is operationally loaded into In 10034, then it is compiled as being transferred to be performed in processor 1002 after machine code, so that being based on von Neumann system Computer system in form thread scheduling function call module 102 in logic, synchrolock add module 104, suspend and perform Module 106, operation function performing module 108, Hash codes correspondence memory module 110 and Hash codes storage remove module 112.And In the above-mentioned multithread scheduling method implementation procedure based on thread pool, the parameter of input is connect by outer input interface 1001 Receive, and be transferred to be cached in memorizer 1003, be then input to be processed in processor 1002, the result data of process or slow It is stored in memorizer 1003 and is subsequently processed, or be passed to output interface 1004 and is exported.
Specifically, processor 1002 is used for performing following operation:
The invoked procedure of the thread scheduling function of detection thread pool, obtains the heap of the corresponding allocating stack of the invoked procedure Stack characteristic information and goal task object, the goal task object is the object for realizing thread interface;
The operation function of the goal task object is called in detection, is added on the operation function of the goal task object Puzzle lock corresponding with the storehouse characteristic information and/or countdown are locked, and detect the locking of the Puzzle lock and/or countdown lock State, the Puzzle lock discharges in threshold value of the Thread Count corresponding with goal task object more than or equal to the Puzzle lock, The countdown is locked in after wait preset duration and discharges;
When the counting and/or countdown lock are in the lock state, suspend the operation for performing the goal task object Function;
When the lock-out state locked in the Puzzle lock or countdown discharges, the operation letter of the goal task object is performed Number.
Optionally, in one embodiment, processor 1002 is also used for performing following operation:
The storehouse characteristic information and goal task of the thread scheduling function call of the thread pool are obtained by Hook Function Object.
Optionally, in one embodiment, processor 1002 is also used for performing following operation:
Counting corresponding with the stack information is added by the operation function that Hook Function is the goal task object Lock or countdown lock.
Optionally, in one embodiment, processor 1002 is also used for performing following operation:
The goal task object is obtained by Hook Function corresponding with the operation function of the goal task object Class name;Judge that whether the class name is the class name of default application to be measured, if so, then perform described in the goal task object Operation function on add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock.
Optionally, in one embodiment, processor 1002 is also used for performing following operation:
The Hash codes of the goal task object are obtained, is stored in the Hash codes are corresponding with the storehouse characteristic information In caching;
It is described to add Puzzle lock corresponding with the storehouse characteristic information on the operation function of the goal task object And/or countdown lock also includes:
Storehouse characteristic information corresponding with the Hash codes of the goal task object is searched, is obtained and storehouse feature letter Cease corresponding Puzzle lock and/or countdown lock.
Optionally, in one embodiment, processor 1002 is also used for performing following operation:
After the lock-out state release that the Puzzle lock or the countdown are locked, by the Hash codes of the goal task object And the storehouse characteristic information of storage corresponding with the Hash codes is removed from the caching.
Above disclosed is only present pre-ferred embodiments, can not limit the right model of the present invention with this certainly Enclose, therefore the equivalent variations made according to the claims in the present invention, still belong to the scope that the present invention is covered.

Claims (12)

1. a kind of multithread scheduling method based on thread pool, it is characterised in that include:
The invoked procedure of the thread scheduling function of detection thread pool, the storehouse for obtaining the corresponding allocating stack of the invoked procedure is special Reference ceases and goal task object, and the goal task object is the object for realizing thread interface;
The operation function of the goal task object is called in detection, addition and institute on the operation function of the goal task object The corresponding Puzzle lock of storehouse characteristic information and/or countdown lock are stated, the locking shape of the Puzzle lock and/or countdown lock is detected State, the Puzzle lock discharges in threshold value of the Thread Count corresponding with goal task object more than or equal to the Puzzle lock, institute State countdown and be locked in after wait preset duration and discharge;
When the counting and/or countdown lock are in the lock state, suspend the operation function for performing the goal task object;
When the lock-out state locked in the Puzzle lock or countdown discharges, the operation function of the goal task object is performed.
2. the multithread scheduling method based on thread pool according to claim 1, it is characterised in that the acquisition tune Included with the storehouse characteristic information and goal task object of the corresponding allocating stack of process:
The storehouse characteristic information and goal task object of the thread scheduling function call of the thread pool are obtained by Hook Function.
3. the multithread scheduling method based on thread pool according to claim 1, it is characterised in that described in the target Adding Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock on the operation function of task object also includes:
By operation function that Hook Function is the goal task object add Puzzle lock corresponding with the stack information or Countdown is locked.
4. the multithread scheduling method based on thread pool according to claim 3, it is characterised in that institute is called in the detection Stating the operation function of goal task object also includes:
The class name of the goal task object is obtained by Hook Function corresponding with the operation function of the goal task object;
Judge that whether the class name is the class name of default application to be measured, if so, then perform described in the goal task object Operation function on add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock.
5. the multithread scheduling method based on thread pool according to claim 1, it is characterised in that the acquisition tune With also including after the storehouse characteristic information and goal task object of the corresponding allocating stack of process:
The Hash codes of the goal task object are obtained, caching is stored in by the Hash codes are corresponding with the storehouse characteristic information In;
It is described add on the operation function of the goal task object Puzzle lock corresponding with the storehouse characteristic information and/or Countdown lock also includes:
Storehouse characteristic information corresponding with the Hash codes of the goal task object is searched, is obtained and the storehouse characteristic information pair The Puzzle lock answered and/or countdown are locked.
6. the multithread scheduling method based on thread pool according to claim 5, it is characterised in that methods described is also wrapped Include:
After the lock-out state release that the Puzzle lock or the countdown are locked, by the Hash codes of the goal task object and The storehouse characteristic information of storage corresponding with the Hash codes is removed from the caching.
7. a kind of multithread scheduling device based on thread pool, it is characterised in that include:
Thread scheduling function call module, for detecting the invoked procedure of the thread scheduling function of thread pool, obtain described in call The storehouse characteristic information and goal task object of the corresponding allocating stack of process, the goal task object connects to realize thread The object of mouth;
Synchrolock add module, for the operation function that the goal task object is called in detection, in the goal task object Operation function on add Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock, detect the Puzzle lock and/ Or the lock-out state of countdown lock, the Puzzle lock is in Thread Count corresponding with goal task object more than or equal to the counting Discharge during the threshold value of lock, the countdown is locked in after wait preset duration and discharges;
Suspend performing module, for when the counting and/or countdown lock are in the lock state, suspending the execution target and appointing The operation function of business object;
Operation function performing module, when the lock-out state for locking in the Puzzle lock or countdown discharges, performs the target The operation function of task object.
8. the multithread scheduling device based on thread pool according to claim 7, it is characterised in that the thread scheduling letter Number calling modules be additionally operable to by hook obtain the thread pool thread scheduling function call storehouse characteristic information and target Task object.
9. the multithread scheduling device based on thread pool according to claim 7, it is characterised in that the synchrolock addition Module is additionally operable to add Puzzle lock corresponding with the stack information by the operation function that hook is the goal task object Or countdown lock.
10. the multithread scheduling device based on thread pool according to claim 9, it is characterised in that the synchrolock adds Plus module is additionally operable to obtain the goal task object by hook corresponding with the operation function of the goal task object Class name;Judge that whether the class name is the class name of default application to be measured, in the entitled default application to be measured of the class During class name, described in execution counting corresponding with the storehouse characteristic information is added on the operation function of the goal task object Lock and/or countdown lock.
The 11. multithread scheduling devices based on thread pool according to claim 7, it is characterised in that described device is also wrapped Hash codes correspondence memory module is included, for obtaining the Hash codes of the goal task object, by the Hash codes and the storehouse The storage of characteristic information correspondence is in the buffer;
The synchrolock add module is additionally operable to search storehouse characteristic information corresponding with the Hash codes of the goal task object, Obtain Puzzle lock corresponding with the storehouse characteristic information and/or countdown lock.
The 12. multithread scheduling devices based on thread pool according to claim 11, it is characterised in that described device is also wrapped Hash codes storage remove module is included, for after the lock-out state release that the Puzzle lock or the countdown are locked, by the mesh The Hash codes of mark task object and the storehouse characteristic information of storage corresponding with the Hash codes are removed from the caching.
CN201611122099.8A 2016-12-08 2016-12-08 Multithreading scheduling method and device based on thread pool Active CN106681811B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611122099.8A CN106681811B (en) 2016-12-08 2016-12-08 Multithreading scheduling method and device based on thread pool

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611122099.8A CN106681811B (en) 2016-12-08 2016-12-08 Multithreading scheduling method and device based on thread pool

Publications (2)

Publication Number Publication Date
CN106681811A true CN106681811A (en) 2017-05-17
CN106681811B CN106681811B (en) 2021-09-14

Family

ID=58868530

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611122099.8A Active CN106681811B (en) 2016-12-08 2016-12-08 Multithreading scheduling method and device based on thread pool

Country Status (1)

Country Link
CN (1) CN106681811B (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463439A (en) * 2017-08-21 2017-12-12 山东浪潮通软信息科技有限公司 A kind of thread pool implementation method and device
CN107577525A (en) * 2017-08-22 2018-01-12 努比亚技术有限公司 A kind of method, apparatus and computer-readable recording medium for creating concurrent thread
CN108052396A (en) * 2017-11-27 2018-05-18 深圳市恒扬数据股份有限公司 A kind of resource allocation methods and system
CN108628668A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 A kind of more countdown task scheduling systems, method, electronic equipment and storage medium
CN108762940A (en) * 2018-04-12 2018-11-06 武汉斗鱼网络科技有限公司 Multi-threaded Access Methods and device
CN108985629A (en) * 2018-07-17 2018-12-11 阿里巴巴集团控股有限公司 The execution method, apparatus and server of service node in business chain
CN109032775A (en) * 2018-06-29 2018-12-18 武汉斗鱼网络科技有限公司 A kind of method, terminal device and storage medium obtaining Task Progress
WO2019006997A1 (en) * 2017-07-01 2019-01-10 武汉斗鱼网络科技有限公司 Program deadlock detection method, storage medium, device and system
CN109324916A (en) * 2018-08-09 2019-02-12 武汉斗鱼网络科技有限公司 A kind of task executing method and device
CN109426702A (en) * 2017-08-31 2019-03-05 武汉斗鱼网络科技有限公司 IOS platform file reads guard method, storage medium, electronic equipment and system
CN109739583A (en) * 2018-12-13 2019-05-10 平安科技(深圳)有限公司 Method, apparatus, computer equipment and the storage medium of multi-threaded parallel operation
CN109783239A (en) * 2019-01-25 2019-05-21 上海创景信息科技有限公司 Multithreading optimization method, system and the medium of SystemC emulation dispatch core
CN110362389A (en) * 2019-05-28 2019-10-22 深圳市道通智能航空技术有限公司 Multithreading exits method and mobile terminal
CN113626244A (en) * 2021-08-26 2021-11-09 广州市百果园网络科技有限公司 ANR abnormal data collection method, ANR abnormal data display method, ANR abnormal data collection device, ANR abnormal data display device and ANR abnormal data display equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
CN103034577A (en) * 2011-10-08 2013-04-10 腾讯科技(深圳)有限公司 Method and device for positioning slow shutdown
CN104516732A (en) * 2013-09-29 2015-04-15 北京新媒传信科技有限公司 Application crash report method and system
US9032249B1 (en) * 2005-08-26 2015-05-12 Open Invention Network, Llc System and method for event-driven live migration of multi-process applications
CN105144117A (en) * 2012-12-14 2015-12-09 微软技术许可有限责任公司 Automated correlation and analysis of callstack and context data
CN105446886A (en) * 2016-01-04 2016-03-30 青岛海信移动通信技术股份有限公司 Computer program debugging method and device
CN105843741A (en) * 2016-03-24 2016-08-10 腾讯科技(深圳)有限公司 Information processing method and device for application program

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
US9032249B1 (en) * 2005-08-26 2015-05-12 Open Invention Network, Llc System and method for event-driven live migration of multi-process applications
CN103034577A (en) * 2011-10-08 2013-04-10 腾讯科技(深圳)有限公司 Method and device for positioning slow shutdown
CN105144117A (en) * 2012-12-14 2015-12-09 微软技术许可有限责任公司 Automated correlation and analysis of callstack and context data
CN104516732A (en) * 2013-09-29 2015-04-15 北京新媒传信科技有限公司 Application crash report method and system
CN105446886A (en) * 2016-01-04 2016-03-30 青岛海信移动通信技术股份有限公司 Computer program debugging method and device
CN105843741A (en) * 2016-03-24 2016-08-10 腾讯科技(深圳)有限公司 Information processing method and device for application program

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
DUANXZ: "ThreadPoolExecutor之三:自定义线程池-扩展示例", 《HTTPS://WWW.CNBLOGS.COM/DUANXZ/P/3380367.HTML》 *
XIEYU_ZY: "Java线程池架构原理和源码解析(ThreadPoolExecutor)", 《HTTPS://BLOG.CSDN.NET/XIEYUOOO/ARTICLE/DETAILS/8718741》 *
ZHANGK64: "Java模拟并发操作进行服务器压力测试", 《HTTPS://BLOG.CSDN.NET/U010642004/ARTICLE/DETAILS/50042781》 *
腾讯BUGLY: "经典随机Crash之一:线程安全", 《HTTPS://MP.WEIXIN.QQ.COM/S/-TJ4FB86TGRNQECYQPY9PA》 *
菜鸟大明: "JAVA模拟瞬间高并发", 《HTTPS://BLOG.CSDN.NET/ZHAO9TIAN/ARTICLE/DETAILS/40346899》 *

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628668B (en) * 2017-03-21 2021-01-26 北京京东尚科信息技术有限公司 Multi-countdown task scheduling system and method, electronic equipment and storage medium
CN108628668A (en) * 2017-03-21 2018-10-09 北京京东尚科信息技术有限公司 A kind of more countdown task scheduling systems, method, electronic equipment and storage medium
WO2019006997A1 (en) * 2017-07-01 2019-01-10 武汉斗鱼网络科技有限公司 Program deadlock detection method, storage medium, device and system
CN109213576A (en) * 2017-07-01 2019-01-15 武汉斗鱼网络科技有限公司 Program deadlock detection method, storage medium, equipment and system
CN107463439A (en) * 2017-08-21 2017-12-12 山东浪潮通软信息科技有限公司 A kind of thread pool implementation method and device
CN107577525A (en) * 2017-08-22 2018-01-12 努比亚技术有限公司 A kind of method, apparatus and computer-readable recording medium for creating concurrent thread
CN107577525B (en) * 2017-08-22 2020-11-17 努比亚技术有限公司 Method and device for creating concurrent threads and computer-readable storage medium
CN109426702A (en) * 2017-08-31 2019-03-05 武汉斗鱼网络科技有限公司 IOS platform file reads guard method, storage medium, electronic equipment and system
CN108052396A (en) * 2017-11-27 2018-05-18 深圳市恒扬数据股份有限公司 A kind of resource allocation methods and system
CN108762940B (en) * 2018-04-12 2020-09-04 武汉斗鱼网络科技有限公司 Multithreading access method and device
CN108762940A (en) * 2018-04-12 2018-11-06 武汉斗鱼网络科技有限公司 Multi-threaded Access Methods and device
CN109032775A (en) * 2018-06-29 2018-12-18 武汉斗鱼网络科技有限公司 A kind of method, terminal device and storage medium obtaining Task Progress
CN108985629B (en) * 2018-07-17 2022-04-08 创新先进技术有限公司 Method and device for executing service node in service chain and server
CN108985629A (en) * 2018-07-17 2018-12-11 阿里巴巴集团控股有限公司 The execution method, apparatus and server of service node in business chain
CN109324916B (en) * 2018-08-09 2022-02-08 武汉斗鱼网络科技有限公司 Task execution method and device
CN109324916A (en) * 2018-08-09 2019-02-12 武汉斗鱼网络科技有限公司 A kind of task executing method and device
CN109739583A (en) * 2018-12-13 2019-05-10 平安科技(深圳)有限公司 Method, apparatus, computer equipment and the storage medium of multi-threaded parallel operation
CN109739583B (en) * 2018-12-13 2023-09-08 平安科技(深圳)有限公司 Method, device, computer equipment and storage medium for parallel running of multiple threads
CN109783239B (en) * 2019-01-25 2021-01-15 上海创景信息科技有限公司 Multithreading optimization method, system and medium of SystemC simulation scheduling core
CN109783239A (en) * 2019-01-25 2019-05-21 上海创景信息科技有限公司 Multithreading optimization method, system and the medium of SystemC emulation dispatch core
CN110362389A (en) * 2019-05-28 2019-10-22 深圳市道通智能航空技术有限公司 Multithreading exits method and mobile terminal
US11853153B2 (en) 2019-05-28 2023-12-26 Autel Robotics Co., Ltd. Multi-thread exit method and mobile terminal
CN113626244A (en) * 2021-08-26 2021-11-09 广州市百果园网络科技有限公司 ANR abnormal data collection method, ANR abnormal data display method, ANR abnormal data collection device, ANR abnormal data display device and ANR abnormal data display equipment

Also Published As

Publication number Publication date
CN106681811B (en) 2021-09-14

Similar Documents

Publication Publication Date Title
CN106681811A (en) Multi-thread scheduling method and device based on thread pool
US9727372B2 (en) Scheduling computer jobs for execution
Huang et al. ShuffleDog: characterizing and adapting user-perceived latency of android apps
US9886305B2 (en) Determining the status of plurality of threads by monitoring the execution of folded thread
US9058417B2 (en) Thread serialization and disablement tool
US8132170B2 (en) Call stack sampling in a data processing system
Kalkov et al. A real-time extension to the Android platform
EP2701074A1 (en) Method, device, and system for performing scheduling in multi-processor core system
CN111488290A (en) Thread testing method and device based on intelligent electric meter operating system
CN106502778A (en) A kind of terminal and its process scheduling optimization method
CN112988185A (en) Cloud application updating method, device and system, electronic equipment and storage medium
CN109117280A (en) The method that is communicated between electronic device and its limiting process, storage medium
CN114327894A (en) Resource allocation method, device, electronic equipment and storage medium
CN113190427A (en) Caton monitoring method and device, electronic equipment and storage medium
CN112035839A (en) Detection method and device for race condition vulnerability exploitation
CN115981962B (en) Thread pool monitoring method and device, electronic equipment and storage medium
CN111901318A (en) Method, system and equipment for detecting command injection attack
CN109918276B (en) Exposure buried point processing method based on APP and related equipment
EP4354293A1 (en) Detection method and apparatus, and electronic device
CN106482742A (en) The acquisition methods of meter step data and device
CN106407016A (en) Method and device for simulating multi-threading resource competition
CN111831409B (en) Thread scheduling method and device, storage medium and electronic equipment
CN113961338A (en) Management system and management method of dynamic thread pool and thread task processing method
CN112463626A (en) Memory leak positioning method and device, computer equipment and storage medium
US9053227B2 (en) Concurrent assertion

Legal Events

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