Merge pull request #10914 from dev-chirag/bael4235

Bael4235 How to find number of threads in a Java process
This commit is contained in:
Jonathan Cook 2021-06-25 17:56:20 +02:00 committed by GitHub
commit 44165b93d4
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
package com.baeldung.concurrent.threads.number;
import java.lang.management.ManagementFactory;
public class FindNumberOfThreads {
public static void main(String[] args) {
System.out.println("Number of threads " + Thread.activeCount());
System.out.println("Current Thread Group - "
+ Thread.currentThread().getThreadGroup().getName());
System.out.println("Total Number of threads "
+ ManagementFactory.getThreadMXBean().getThreadCount());
}
}