Exercises 2
Create an application that displays the number of threads and ThreadGroups which are running in the Java Virtual Machine (activeCount(), activeGroupCount() ).
Modify the previous example in order to also display the names (getName()) and priorities (getPriority() / getMaxPriority()), of the threads and their respective ThreadGroups. For the threads, also indicate whether they are daemon threads (isDaemon()) and if they are alive (isAlive()). Use the thread methods currentThread() and getThreadGroup() to move through the system’s threads in order to find the “root” ThreadGroup (getParent() returns null) and from there start listing the various threads/groups recursively. Finally, display your results in a TextArea.