Tuesday, March 26, 2002 03:43 AM
You can enumerate around all the threads in a given ThreadGroup using the static 'Thread.enumerate()' method and the number of threads in a group is given by the static 'Thread.activeCount()' method. This might give you what you want if all threads are in the same group (or one of its children). I'm not sure if it will report any additional threads used internally by the JVM.
public class TT
public static void main( String  args )
System.out.println("Number of threads ("+Thread.activeCount()+")");
returns '1' for me when running under native threads on Solaris 2.6.