private void displayThreads() {
        ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
        ThreadGroup parentGroup;
        while ((parentGroup = rootGroup.getParent()) != null )
            rootGroup = parentGroup;

        Thread[] threads = new Thread[rootGroup.activeCount()];
        while (rootGroup.enumerate(threads, true) == threads.length)
            threads = new Thread[threads.length * 2];

        out.println("Name\t\t\t\t\tPrior\tState");
        for (int i = 0; i < threads.length && threads[i] != null; i ++) {
            Thread t = threads[i];
            String line = t.getName();
            
            while (line.length() < 40)
                line += " ";
            
            line += t.getPriority() + "\t" + t.getState();
            
            out.println(line);
        }
    }