private static Thread[] getThreads(ThreadGroup g) {
        int mul = 1;
        do {
            Thread[] arr = new Thread[g.activeCount() * mul + 1];
            if (g.enumerate(arr) < arr.length) {
                return arr;
            }
            mul++;
        } while (true);
    }
private static Thread [ ] getThreads ( ThreadGroup g ) { int mul = 1 ; do { Thread [ ] arr = new Thread [ g . activeCount ( ) * mul + 1 ] ; if ( g . enumerate ( arr ) < arr . length ) { return arr ; } mul ++ ; } while ( true ) ; }
Returns threads in an array. Some elements may be null.