Switch-vov commented on a change in pull request #7243:
URL: https://github.com/apache/skywalking/pull/7243#discussion_r664286685



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/thread/ThreadProvider.java
##########
@@ -31,12 +32,58 @@
     }
 
     public Thread getThreadMetrics() {
+        int newStateThreadCount = 0;
+        int runnableStateThreadCount = 0;
+        int blockedStateThreadCount = 0;
+        int waitingStateThreadCount = 0;
+        int timedWaitingStateThreadCount = 0;
+        int terminatedStateThreadCount = 0;
+
+        ThreadInfo[] threadInfos = 
threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), 0);
+        if (threadInfos != null) {
+            for (ThreadInfo threadInfo : threadInfos) {
+                if (threadInfo != null) {
+                    switch (threadInfo.getThreadState()) {
+                        case NEW:
+                            newStateThreadCount++;
+                            break;
+                        case RUNNABLE:
+                            runnableStateThreadCount++;
+                            break;
+                        case BLOCKED:
+                            blockedStateThreadCount++;
+                            break;
+                        case WAITING:
+                            waitingStateThreadCount++;
+                            break;
+                        case TIMED_WAITING:
+                            timedWaitingStateThreadCount++;
+                            break;
+                        case TERMINATED:
+                            terminatedStateThreadCount++;
+                            break;
+                        default:
+                            break;
+                    }
+                } else {
+                    terminatedStateThreadCount++;
+                }

Review comment:
       > > If you remove the counting logic from the else code block, you may 
find that the `Terminated State` is zero always.
   > 
   > Of course.
   > 
   > So, I remove `Terminated State` and `New State` later.
   
   I remove it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to