CN109542719B - Thread state monitoring method and device, computer equipment and storage medium - Google Patents

Thread state monitoring method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN109542719B
CN109542719B CN201811257367.6A CN201811257367A CN109542719B CN 109542719 B CN109542719 B CN 109542719B CN 201811257367 A CN201811257367 A CN 201811257367A CN 109542719 B CN109542719 B CN 109542719B
Authority
CN
China
Prior art keywords
thread
state
stack
current
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811257367.6A
Other languages
Chinese (zh)
Other versions
CN109542719A (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.)
Kingdee Software China Co Ltd
Original Assignee
Kingdee Software China 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 Kingdee Software China Co Ltd filed Critical Kingdee Software China Co Ltd
Priority to CN201811257367.6A priority Critical patent/CN109542719B/en
Publication of CN109542719A publication Critical patent/CN109542719A/en
Application granted granted Critical
Publication of CN109542719B publication Critical patent/CN109542719B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system

Landscapes

  • Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to a thread state monitoring method, a thread state monitoring device, computer equipment and a storage medium. The thread state monitoring method comprises the following steps: acquiring a thread stack generated in the application running process; acquiring a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, wherein the method state stack comprises method state information of each method on the thread; determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency. By using the method, the method state information of each method specifically executed on each thread of the application can be checked, so that which method on which thread has a problem can be accurately obtained according to the state information, and the performance of the method with the problem is optimized.

Description

Thread state monitoring method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for monitoring a thread state, a computer device, and a storage medium.
Background
When a computer runs an application program and the application program is stuck for a long time, the running state of the application program needs to be analyzed. Generally, a thread stack generated during the running of the application program is analyzed, and then a method (which may also be referred to as a function) on which thread is specified is found to be in a problem in the thread stack, so that the method of the thread is optimized, and the application program runs normally.
In the conventional technology, in the running process of an application program, generally, an application server where Java is located is logged in and run first, then a jstack (stack tracking tool) command of jvm (Java virtual machine) is run to obtain a thread stack of the application program, then the thread stack information of the application program is analyzed, and a specific thread is located, so that all methods of the thread are optimized, and the application program runs normally.
However, the above method cannot locate which method of the thread is in question, and thus cannot accurately optimize the method on the thread.
Disclosure of Invention
Therefore, it is necessary to provide a method and an apparatus for monitoring a thread state, a computer device, and a storage medium for solving the problem that the conventional technology cannot locate which method of a thread is a problem, and thus cannot accurately optimize the method on the thread.
A thread state monitoring method comprises the following steps:
acquiring a thread stack generated in the application running process;
according to each thread in the thread stack, acquiring a method state stack corresponding to each thread from a preset global thread state table, wherein the method state stack comprises method state information of each method on the thread;
determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
In one embodiment, the method state information includes an identification of the method, a start runtime of the method.
In one embodiment, the method state information further includes non-time parameter information of the method, and the non-time parameter information includes at least one of the executed database script and a request address parameter corresponding to the method.
In one embodiment, the determining the method state on each thread according to the method state information in each method state stack includes:
acquiring the current system operation time;
determining the continuous operation duration of each method on each thread according to the current system operation time and the starting operation time of each method in each method state stack;
and determining the method state of each method on each thread according to the comparison result of the continuous operation time length of each method on each thread and the preset time length.
In one embodiment, before acquiring the thread stack generated during the running of the application, the method further includes:
acquiring an identifier of a current thread of application operation;
judging whether a method state stack corresponding to the current thread identifier exists in a current global thread state table or not according to the identifier of the current thread;
and if not, creating a method state stack corresponding to the current thread in a current global thread state table according to each method on the current thread.
In one embodiment, the creating, according to each method on the current thread, a method state stack corresponding to the current thread in a current global thread state table includes:
creating an empty stack in a current global thread state table according to a preset rule;
acquiring the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread;
and adding the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread to the empty stack to form a method state stack corresponding to the current thread.
In one embodiment, the thread state monitoring method further includes:
and if the method on each thread executes the return operation, deleting the method state information corresponding to the method from the global thread state table.
In one embodiment, the thread state monitoring method further includes:
formatting the format of the method state information of each method on the thread, and outputting the formatted method state information to a web page.
A thread condition monitoring device, comprising:
the first acquisition module is used for acquiring a thread stack generated in the application running process;
a second obtaining module, configured to obtain, according to each thread in the thread stack, a method state stack corresponding to each thread from a preset global thread state table, where the method state stack includes method state information of each method on the thread;
the determining module is used for determining the method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
A computer device, comprising: a memory and a processor, the memory storing a computer program, wherein the processor implements the following steps when executing the computer program:
acquiring a thread stack generated in the application running process;
acquiring a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, wherein the method state stack comprises method state information of each method on the thread;
determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
A storage medium having a computer program stored thereon, the computer program, when executed by a processor, performing the steps of:
acquiring a thread stack generated in the application running process;
acquiring a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, wherein the method state stack comprises method state information of each method on the thread;
determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
According to the thread state monitoring method, computer equipment firstly acquires a thread stack generated in the running process of an application, then acquires a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, the method state stack comprises method state information of each method on the thread, and finally determines the method state on each thread according to the method state information in each method state stack, wherein the method state is a stuck running state or a smooth running state. By using the method of the embodiment, the method state information of each method specifically executed on each thread of the application can be checked, so that which method on which thread has a problem can be accurately obtained according to the state information, and the performance of the method having the problem is optimized; meanwhile, the method can avoid blindly optimizing the performance of all methods on the thread, thereby improving the efficiency of the computer equipment for optimizing the method performance of the thread.
Drawings
FIG. 1 is a diagram of an embodiment of a thread state monitoring method;
FIG. 2 is a flowchart illustrating a thread state monitoring method according to an embodiment;
FIG. 3 is a flowchart illustrating a thread state monitoring method according to an embodiment;
FIG. 4 is a flowchart of a thread state monitoring method according to an embodiment;
FIG. 5 is a flowchart of a thread state monitoring method according to an embodiment;
FIG. 6 is a block diagram of a thread state monitoring apparatus according to an embodiment;
FIG. 7 is a block diagram of a thread state monitoring apparatus according to an embodiment;
fig. 8 is a schematic structural diagram of a thread state monitoring apparatus according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The thread state monitoring method provided by the embodiment of the invention can be applied to the computer equipment shown in FIG. 1. As shown in fig. 1, the computer apparatus includes a processor, a memory, a network interface, a display screen, and an input device, which are connected through a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external computer through a network connection. The computer program is executed by a processor to implement a thread status monitoring method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
It should be noted that the structure shown in fig. 1 is a block diagram of only a part of the structure related to the present application, and does not constitute a limitation on the computer device to which the present application is applied, and a specific computer device may include more or less components than those shown in the drawings, or combine some components, or have a different arrangement of components.
Before describing particular embodiments, specific terms or concepts related to embodiments of the present invention are explained herein:
thread stacking: and the thread snapshot of the application program at the current moment is a set of method stacks executed by each thread when the application program in the current java virtual machine runs.
In the conventional technology, when an application program is stuck for a long time in the running process, a computer device runs a jstack command of jvm to obtain a thread stack of the application program, and then, by analyzing the thread stack information of the application program and locating which thread has a problem, all methods of the thread are optimized, so that the application program runs normally. However, the method cannot specifically determine which method of the thread is in question, so that the method on the thread cannot be optimized accurately, and the optimization efficiency is low. The embodiment of the invention provides a thread state monitoring method, a thread state monitoring device, computer equipment and a storage medium, and aims to solve the technical problems in the prior art.
It should be noted that the execution subject of the method embodiments described below may be a thread state monitoring apparatus, and the thread state monitoring apparatus may be implemented as part or all of the computer device in a software, hardware, or a combination of software and hardware. The method embodiments described below are described by way of example with the execution subject being a computer device.
Fig. 2 is a flowchart illustrating a thread state monitoring method according to an embodiment. The embodiment relates to a specific process of monitoring the method state on a thread generated in the running process of an application by a computer device. As shown in fig. 2, the method may include the steps of:
s201, acquiring a thread stack generated in the application running process.
Specifically, after the application starts to run on the computer device, a thread is generated; optionally, one or more threads may be generated during the application runtime; each generated thread has a corresponding method, and optionally, the corresponding method on each thread may be one or more; the set of methods on the threads described above constitutes a thread stack. Optionally, the computer device may use a jstack command to obtain the thread stack; optionally, the computer device may obtain the thread stack when a checkpoint occurs in an application running process, or may obtain the thread stack when the application runs smoothly, which is not limited in this embodiment.
S202, according to each thread in the thread stack, obtaining a method state stack corresponding to each thread from a preset global thread state table, wherein the method state stack comprises method state information of each method on the thread.
Specifically, the preset global state table may include an identifier of each thread and a method state stack corresponding to each thread, where the method state stack includes method state information of each method on the thread. Optionally, when the computer device needs to check information of the thread stack, the computer device may traverse all the threads in the global thread state table according to the thread identifier to obtain method state stacks corresponding to all the threads. The methods in the above methods may be referred to as functions, and for example, functions executable on one thread may call a certain function, or access a certain address.
S203, determining the method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
Specifically, in the global thread state table, each thread has a corresponding method state stack, and each method state stack has method state information of each method on the thread; optionally, the method state information may include an identifier of the method on each thread and a start running time of the method, so that a user may conveniently view the state information of the corresponding method in a method state stack of the global thread state table, and further characterize a running state of the method by using the start running time of the method. Optionally, the method state information may further include non-time parameter information of the method, where the non-time parameter information includes at least one of an executed database script and a request address parameter corresponding to the method, so that when the computer device monitors the method on each thread, more comprehensive information about each method on a current thread can be obtained, and the computer device can have a more accurate analysis result on the running state of the method. Optionally, the non-time parameter may also be another parameter, which is not limited in this embodiment. After obtaining the method state information in the corresponding method state stack on each thread, the computer device can judge whether the method state on each thread runs on a stuck state or a smooth state according to the method state information.
As can be seen from the above description, in the thread state monitoring method provided in this embodiment, when an application running state has a problem, the method state information in the method state stack on the preset global thread state table is used to determine the state of the method on the thread, so as to locate which thread method has a problem, which is different from the method that blindly optimizes the performance of all methods on the thread in the conventional technology; therefore, by using the thread state monitoring method provided by the embodiment, when the running state of the application has a problem, the method state information of each method specifically executed on each thread of the application can be seen, so that which method on which thread has a problem can be accurately positioned according to the state information, and the performance of the method having the problem can be optimized in a targeted manner; meanwhile, the method can avoid blindly optimizing the performance of all methods on the thread, thereby improving the efficiency of the computer equipment for optimizing the method performance of the thread.
In the thread state monitoring method provided in this embodiment, the computer device first obtains a thread stack generated by the application in the running process, and then obtains a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack. Because the method state stack comprises the method state information of each method on the thread, the method state on each thread can be determined according to the method state information in each method state stack, and the method can be operated in a stuck state or smoothly, so that the method of the embodiment can accurately obtain which method on which thread has a problem, and further optimize the performance of the method with the problem; meanwhile, the method can avoid blindly optimizing the performance of all methods on the thread, thereby improving the efficiency of the computer equipment for optimizing the method performance of the thread.
Fig. 3 is a flowchart illustrating a thread state monitoring method according to an embodiment. This embodiment relates to a specific process of how a computer device determines the method state on each thread based on the method state information in each method state stack. On the basis of the above embodiment, referring to fig. 3, the step S203 includes the following steps:
s301, obtaining the current system running time.
S302, according to the current system running time and the starting running time of each method in each method state stack, determining the continuous running time of each method on each thread.
Specifically, after obtaining the running time of the current system and the starting running time of each method in each method state stack, the computer device may optionally make a difference between the current system time and the starting running time of each method in each method state stack, so as to obtain the duration of running of each method on each thread.
S303, determining the method state of each method on each thread according to the comparison result of the continuous operation time length of each method on each thread and the preset time length.
Specifically, after obtaining the duration of each method on each thread, the computer device may compare the duration with a preset duration, so as to obtain a comparison result. Optionally, the comparison may be performed by making a difference between the duration of the continuous operation of each method and a preset duration, and obtaining a comparison result according to the difference; when the comparison result shows that the continuous operation duration of each method is longer than the preset duration, the computer equipment can determine that the method state of the method is operation halt; and when the comparison result shows that the continuous operation time of each method is not more than the preset time, the computer equipment can determine that the method state of the method is smooth in operation. Optionally, the comparison may also be performed by comparing the duration of each method with a preset duration, and then comparing the ratio with 1 to obtain a comparison result. When the comparison result is that the ratio is greater than 1, the computer equipment can determine that the method state of the method is operating pause; when the comparison result is that the ratio is not greater than 1, the computer device may determine that the method state of the method is running smoothly.
In the thread state monitoring method provided in this embodiment, the computer device first obtains the current system running time, then according to the current system running time and the starting running time of each method in each method state stack, the computer device can determine the continuous running time of each method on each thread, finally, the running time of the computer device is compared with the preset time, and the method state of each method on each thread is determined according to the comparison result. Therefore, by using the method of the embodiment, the running time of each method on each thread can be clearly and accurately seen, so that the continuous running time of each method is obtained; meanwhile, the method states of the methods on each thread can be determined simply and accurately by comparing the continuous operation time of each method with the preset time length, so that which method on which thread has a problem can be determined quickly according to the method states, and the performance of the method with the problem is optimized quickly and accurately.
Fig. 4 is a flowchart illustrating a thread state monitoring method according to an embodiment. This embodiment relates to a specific process of how a computer device creates a method state stack in a global thread state table. On the basis of the above embodiment, referring to fig. 4, the method further includes the following steps:
s401, obtaining the identification of the current thread of the application operation.
Specifically, the application of the computer device may generate a thread when running, each thread may have a corresponding identifier, and the computer device may obtain the identifier corresponding to the current thread when the application is running.
S402, judging whether a method state stack corresponding to the current thread identifier exists in a current global thread state table according to the identifier of the current thread. If yes, go to S403, otherwise go to S404.
Specifically, an empty global thread state table may be created when the computer device begins to run. After the computer device obtains the identifier of the current thread, it can look up in the current global thread state table to see whether there is a thread identifier matching with the current thread identifier and a corresponding method state stack in the current global thread state table.
And S403, determining the method state of each method on the current thread according to the method state information in the method state stack corresponding to the current thread identifier.
S404, according to each method on the current thread, a method state stack corresponding to the current thread is created in a current global thread state table.
In this step, the computer device determines that if there is no thread identifier and corresponding method state stack matching the current thread identifier in the current global thread state table, then creates a current thread identifier and corresponding method state stack in the current global thread state table according to the current thread identifier and each method on the current thread. Optionally, fig. 5 is a flowchart illustrating a thread state monitoring method according to an embodiment. The method for creating the state stack can comprise the following steps as shown in fig. 5:
s501, creating an empty stack in the current global thread state table according to a preset rule.
Specifically, when the computer device creates a method state stack corresponding to the current thread in the global thread state table, a method state stack corresponding to the current thread may be created in the current global thread state word according to the identifier of the current thread, and the method state stack may be an empty stack, that is, the method state stack does not contain method state information of a method corresponding to the current thread.
S502, obtaining the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread.
Specifically, after the empty stack of the method state stack is created, the computer device may obtain state information of the current method according to thread stack information generated in the application running process, where the state information of the method may be an identifier of each corresponding method on the current thread, a start running time of each method on the current thread, and non-time parameter information of each method on the current thread; optionally, the identifier of each method may be a number, a letter, or the like, which is not limited in this embodiment; optionally, the non-time parameter information of each method may be one or more, which is not limited in this embodiment.
And S503, adding the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread to the empty stack to form a method state stack corresponding to the current thread.
Specifically, after obtaining the method state information on the current thread, that is, the identifiers of the corresponding methods, the start running time of the methods on the current thread, and the non-time parameter information of the methods on the current thread, the computer device may store the method state information in the created empty method state stack to form a method state stack corresponding to the current thread including the method state information. Optionally, the computer device may further label the specified method on the thread generated in the application running process, obtain method state information of the method corresponding to the label, and put the method state information corresponding to the method into the method state stack corresponding to the current thread, so as to monitor the specified method on the thread in a targeted manner, thereby avoiding the computer device from blindly searching for a method with problems on the thread, accurately and quickly finding out a method with problems, and improving the efficiency of finding a method with problems on the thread.
Therefore, in the running process of the application of the computer equipment, the method state stack of the generated thread is continuously stored in the global thread state table.
Optionally, the method may further include: and if the method on each thread executes the return operation, deleting the method state information corresponding to the method from the global thread state table.
In this alternative embodiment, when the application runs out, that is, when the method on each thread performs a return operation, the computer device may delete the identification of the method, the start run time of the method, and the non-time parameter of the method from the global thread state table; optionally, the return may be a normal return when the method operation is finished, or may be an abnormal return during the method operation and/or when the method operation is finished. By using the method, on one hand, the memory occupation loss in the global thread state table can be reduced, and on the other hand, the computer equipment can quickly and accurately position which method of which thread has a problem according to the method state information on the rest threads, and the performance of the method with the problem is optimized.
Optionally, the method may further include: formatting the format of the method state information of each method on the thread, and outputting the formatted method state information to a web page. In this optional embodiment, the computer device formats the format of the method status information, may format one of the information of the method status information, and may format all the information of the method status information, which is not limited in this embodiment. By using the method, the computer equipment can output the method state information in a specific format, so that the user can conveniently check the method state information; in addition, the computer equipment outputs the state information of the method to a web interface, so that a user can visually and conveniently check the state information of each method on each thread, the user can quickly and accurately position which method of which thread has a problem, and the performance of the method with the problem is optimized.
In the thread state monitoring method provided by this embodiment, before acquiring a thread stack generated in an application running process, a computer device first acquires an identifier of a current thread of application running, and then determines whether a method state stack corresponding to the current thread identifier exists in a current global thread state table according to the identifier of the current thread; if the current global thread state table does not have a thread identifier matched with the current thread identifier and a corresponding method state stack, the computer equipment creates an empty stack in the global thread state table according to the current thread identifier and each method on the current thread, and stores the obtained identifier of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread into the empty stack to form the method state stack corresponding to the current thread containing the method state information. Therefore, the computer equipment can monitor the specific method state information of each method of all threads generated in the application running process, accurately position which method of which thread has a problem according to the specific method state information, and pertinently optimize the performance of the method with the problem.
It should be understood that although the various steps in the flow charts of fig. 2-5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-5 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
Fig. 6 is a schematic structural diagram of a thread state monitoring apparatus according to an embodiment. As shown in fig. 6, the apparatus may include: the device comprises a first acquisition module 10, a second acquisition module 11 and a determination module 12.
Specifically, the first obtaining module 10 is configured to obtain a thread stack generated in an application running process;
a second obtaining module 11, configured to obtain, according to each thread in the thread stack, a method state stack corresponding to each thread from a preset global thread state table, where the method state stack includes method state information of each method on the thread;
a determining module 12, configured to determine a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
In one embodiment, the method state information includes an identification of the method, a start runtime of the method.
In one embodiment, the method state information further includes non-temporal parameter information of the method, the non-temporal parameter information including at least one of an executed database script, a request address parameter corresponding to the method.
The thread state monitoring apparatus provided in this embodiment may implement the above method embodiments, and the implementation principle and technical effect are similar, which are not described herein again.
Fig. 7 is a schematic structural diagram of a thread state monitoring apparatus according to an embodiment. On the basis of the above embodiment, as shown in fig. 7, the determining module 12 includes: a first acquiring unit 121, a first determining unit 122, and a second determining unit 123.
Specifically, the first obtaining unit 121 is configured to obtain a current system running time;
a first determining unit 122, configured to determine, according to the current system runtime and the start runtime of each method in each method state stack, a duration of running of each method on each thread;
a second determining unit 123, configured to determine a method state of each method on each thread according to a comparison result between the duration of each method on each thread and the preset duration.
Fig. 8 is a schematic structural diagram of a thread state monitoring apparatus according to an embodiment. On the basis of the foregoing embodiment, as shown in fig. 8, before the obtaining a thread stack generated during the running of the application, the apparatus further includes: a third obtaining module 13, a judging module 14 and a creating module 15.
Specifically, the third obtaining module 13 is configured to obtain an identifier of a current thread in which the application runs;
a judging module 14, configured to judge, according to the identifier of the current thread, whether a method state stack corresponding to the current thread identifier exists in a current global thread state table;
a creating module 15, configured to create a method state stack corresponding to the current thread in the current global thread state table according to each method on the current thread if the method state stack corresponding to the current thread identifier does not exist in the current global thread state table.
On the basis of the above embodiment, with continued reference to fig. 8, the above creation module 15 includes: a creation unit 151, a second acquisition unit 152, an addition unit 153.
Specifically, the creating unit 151 is configured to create an empty stack in the current global thread state table according to a preset rule;
a second obtaining unit 152, configured to obtain an identifier of each method on the current thread, a start running time of each method on the current thread, and non-time parameter information of each method on the current thread;
an adding unit 153, configured to add, to the empty stack, the identifier of each method on the current thread, the start running time of each method on the current thread, and non-time parameter information of each method on the current thread, so as to form a method state stack corresponding to the current thread.
On the basis of the above embodiment, with continued reference to fig. 8, the above apparatus further includes: and deleting the module 16.
Specifically, the deleting module 16 is configured to delete the method state information corresponding to the method from the global thread state table if the method on each thread performs the return operation.
On the basis of the above embodiment, with continued reference to fig. 8, the above apparatus further includes: and an output module 17.
And the output module 17 is configured to format the format of the method state information of each method on the thread, and output the formatted method state information to a web page.
The thread state monitoring apparatus provided in this embodiment may implement the above method embodiments, and the implementation principle and technical effect are similar, which are not described herein again.
In one embodiment, there is provided a computer device comprising: a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program:
acquiring a thread stack generated in the application running process;
acquiring a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, wherein the method state stack comprises method state information of each method on the thread;
determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
In one embodiment, the method state information includes an identification of the method, a start runtime of the method.
In one embodiment, the method state information further includes non-temporal parameter information of the method, the non-temporal parameter information including at least one of an executed database script, a request address parameter corresponding to the method.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
acquiring the current system operation time;
determining the continuous operation duration of each method on each thread according to the current system operation time and the starting operation time of each method in each method state stack;
and determining the method state of each method on each thread according to the comparison result of the continuous operation time length of each method on each thread and the preset time length.
In one embodiment, the processor when executing the computer program further performs the steps of:
acquiring an identifier of a current thread of application operation;
judging whether a method state stack corresponding to the current thread identifier exists in a current global thread state table or not according to the identifier of the current thread;
and if not, creating a method state stack corresponding to the current thread in a current global thread state table according to each method on the current thread.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
creating an empty stack in a current global thread state table according to a preset rule;
acquiring the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread;
and adding the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread to the empty stack to form a method state stack corresponding to the current thread.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and if the method on each thread executes the return operation, deleting the method state information corresponding to the method from the global thread state table.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
formatting the format of the method state information of each method on the thread, and outputting the formatted method state information to a web page.
In one embodiment, a readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, performs the steps of:
acquiring a thread stack generated in the application running process;
acquiring a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, wherein the method state stack comprises method state information of each method on the thread;
determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
In one embodiment, the method state information includes an identification of the method, a start runtime of the method.
In one embodiment, the method state information further includes non-temporal parameter information of the method, the non-temporal parameter information including at least one of an executed database script, a request address parameter corresponding to the method.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring the current system operation time;
determining the continuous operation duration of each method on each thread according to the current system operation time and the starting operation time of each method in each method state stack;
and determining the method state of each method on each thread according to the comparison result of the continuous operation time length of each method on each thread and the preset time length.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring an identifier of a current thread of application operation;
judging whether a method state stack corresponding to the current thread identifier exists in a current global thread state table or not according to the identifier of the current thread;
and if not, creating a method state stack corresponding to the current thread in a current global thread state table according to each method on the current thread.
In one embodiment, the computer program when executed by the processor further performs the steps of:
creating an empty stack in a current global thread state table according to a preset rule;
acquiring the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread;
and adding the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread to the empty stack to form a method state stack corresponding to the current thread.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and if the method on each thread executes the return operation, deleting the method state information corresponding to the method from the global thread state table.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and formatting the format of the method state information of each method on the thread, and outputting the formatted method state information to a web page.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A thread state monitoring method is characterized by comprising the following steps:
acquiring a thread stack generated in the application running process;
acquiring a method state stack corresponding to each thread from a preset global thread state table according to each thread in the thread stack, wherein the method state stack comprises method state information of each method on the thread; the method state information includes an identification of the method, a start runtime of the method;
determining a method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
2. The thread state monitoring method according to claim 1, wherein the method state information further comprises non-temporal parameter information of the method, the non-temporal parameter information comprising at least one of a database script to be executed and a request address parameter corresponding to the method.
3. The thread state monitoring method according to claim 1 or 2, wherein the determining the method state on each thread according to the method state information in each method state stack comprises:
acquiring the current system operation time;
determining the continuous operation duration of each method on each thread according to the current system operation time and the starting operation time of each method in each method state stack;
and determining the method state of each method on each thread according to the comparison result of the continuous operation time length of each method on each thread and the preset time length.
4. The thread state monitoring method according to claim 1 or 2, wherein before the obtaining of the thread stack generated during the application running process, the method further comprises:
acquiring an identifier of a current thread of application operation;
judging whether a method state stack corresponding to the current thread identifier exists in a current global thread state table or not according to the identifier of the current thread;
and if not, creating a method state stack corresponding to the current thread in a current global thread state table according to each method on the current thread.
5. The thread state monitoring method according to claim 4, wherein the creating, according to each method on the current thread, a method state stack corresponding to the current thread in a current global thread state table includes:
creating an empty stack in a current global thread state table according to a preset rule;
acquiring the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread;
and adding the identification of each method on the current thread, the starting running time of each method on the current thread and the non-time parameter information of each method on the current thread into the empty stack to form a method state stack corresponding to the current thread.
6. The thread state monitoring method of claim 1, further comprising:
and if the method on each thread executes the return operation, deleting the method state information corresponding to the method from the global thread state table.
7. The thread state monitoring method of claim 1, further comprising:
formatting the format of the method state information of each method on the thread, and outputting the formatted method state information to a web page.
8. A thread state monitoring device, comprising:
the first acquisition module is used for acquiring a thread stack generated in the application running process;
a second obtaining module, configured to obtain, according to each thread in the thread stack, a method state stack corresponding to each thread from a preset global thread state table, where the method state stack includes method state information of each method on the thread; the method state information includes an identification of the method, a start runtime of the method;
the determining module is used for determining the method state on each thread according to the method state information in each method state stack; the method state comprises method operation blockage and method operation fluency.
9. A computer device, comprising: memory storing a computer program, and a processor, wherein the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A storage medium having a computer program stored thereon, the computer program, when being executed by a processor, performing the steps of the method as set forth in any one of claims 1-7.
CN201811257367.6A 2018-10-26 2018-10-26 Thread state monitoring method and device, computer equipment and storage medium Active CN109542719B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811257367.6A CN109542719B (en) 2018-10-26 2018-10-26 Thread state monitoring method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811257367.6A CN109542719B (en) 2018-10-26 2018-10-26 Thread state monitoring method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109542719A CN109542719A (en) 2019-03-29
CN109542719B true CN109542719B (en) 2022-05-13

Family

ID=65845666

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811257367.6A Active CN109542719B (en) 2018-10-26 2018-10-26 Thread state monitoring method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109542719B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112743260B (en) * 2019-10-30 2022-10-18 北京配天技术有限公司 Robot welding control method, robot welding control apparatus, and storage medium
CN112882902B (en) * 2021-03-05 2023-02-14 深圳市迅雷网络技术有限公司 Thread source obtaining method, electronic equipment and computer readable storage device
CN113608982A (en) * 2021-07-27 2021-11-05 远景智能国际私人投资有限公司 Function execution performance monitoring method and device, computer equipment and storage medium
CN113900910A (en) * 2021-12-08 2022-01-07 北京新唐思创教育科技有限公司 Application program monitoring method and device, storage medium and electronic equipment
CN115168059B (en) * 2022-09-07 2022-12-16 平安银行股份有限公司 System kernel monitoring method and device, terminal equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226487A (en) * 2008-01-30 2008-07-23 中国船舶重工集团公司第七〇九研究所 Method for implementing inner core level thread library based on built-in Linux operating system
CN104657248A (en) * 2013-11-21 2015-05-27 中国移动通信集团山东有限公司 Java thread stack analysis method and system
CN106502773A (en) * 2016-10-09 2017-03-15 武汉斗鱼网络科技有限公司 There is data asynchronous processing method and the module of synchronous callback information function
CN107045478A (en) * 2017-04-28 2017-08-15 福建星瑞格软件有限公司 A kind of lightweight Thread Analysis and operation method for visualizing
CN108345524A (en) * 2017-01-22 2018-07-31 腾讯科技(深圳)有限公司 Method for monitoring application program and Application Monitoring device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20110065067A (en) * 2009-12-09 2011-06-15 삼성전자주식회사 Apparatus for providing visual interface of error information generated in multi-thread testing and method thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226487A (en) * 2008-01-30 2008-07-23 中国船舶重工集团公司第七〇九研究所 Method for implementing inner core level thread library based on built-in Linux operating system
CN104657248A (en) * 2013-11-21 2015-05-27 中国移动通信集团山东有限公司 Java thread stack analysis method and system
CN106502773A (en) * 2016-10-09 2017-03-15 武汉斗鱼网络科技有限公司 There is data asynchronous processing method and the module of synchronous callback information function
CN108345524A (en) * 2017-01-22 2018-07-31 腾讯科技(深圳)有限公司 Method for monitoring application program and Application Monitoring device
CN107045478A (en) * 2017-04-28 2017-08-15 福建星瑞格软件有限公司 A kind of lightweight Thread Analysis and operation method for visualizing

Also Published As

Publication number Publication date
CN109542719A (en) 2019-03-29

Similar Documents

Publication Publication Date Title
CN109542719B (en) Thread state monitoring method and device, computer equipment and storage medium
CN108768728B (en) Operation and maintenance task processing method and device, computer equipment and storage medium
US10409892B2 (en) Formatting data by example
US20200167671A1 (en) Computer system and method for machine learning or inference
US20070136402A1 (en) Automatic prediction of future out of memory exceptions in a garbage collected virtual machine
CN111008188A (en) Data migration method and device, computer equipment and storage medium
CN111190753B (en) Distributed task processing method and device, storage medium and computer equipment
US8443178B2 (en) Operating system image shrinking apparatus and method and computer readable tangible medium storing a program for operating system image shrinking
CN111026663B (en) Software defect detection method, device, computer equipment and storage medium
CN110955508B (en) Asynchronous task scheduling method and device based on distributed architecture and computer equipment
CN108763046B (en) Thread running monitoring method, device, computer equipment and storage medium
US20100073374A1 (en) Calculating a webpage importance from a web browsing graph
US20110078657A1 (en) Operation management server, rollback execution method, and rollback execution program
CN110674145A (en) Data consistency detection method and device, computer equipment and storage medium
KR20150096478A (en) Programmable controller, programmable controller system, and execute error information creation method
CN110324410B (en) Method, device, computer equipment and storage medium for initiating webpage request
CN102262573A (en) Operating system (OS) start-up protecting method and device
CN110231921B (en) Log printing method, device, equipment and computer readable storage medium
CN108804239B (en) Platform integration method and device, computer equipment and storage medium
CN114138734A (en) Web-based version management method facing database and file resource
JP2016057658A (en) Fault information management system and fault information management method
CN111176930B (en) Component operation data processing method and device, computer equipment and storage medium
CN113824590A (en) Method for predicting problem of micro service network, computer device and storage medium
CN109901998B (en) Resource recovery method, device, system, computer equipment and storage medium
CN112463783A (en) Index data monitoring method and device, computer equipment and storage medium

Legal Events

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