diff --git a/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/threads/number/FindNumberOfThreads.java b/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/threads/number/FindNumberOfThreads.java new file mode 100644 index 0000000000..24c897fd11 --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/threads/number/FindNumberOfThreads.java @@ -0,0 +1,12 @@ +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()); + } +}