I\'d like to create a thread that keeps track of the memory usage and cpu usage.
If the application reaches a high level, I want to generate an heap dump or a thread
To dump the threads to the standard out, you may do something like this
ThreadInfo[] threads = ManagementFactory.getThreadMXBean()
.dumpAllThreads(true, true);
for (ThreadInfo info : threads) {
System.out.print(info);
}
in Java 6 using the ThreadMXBean class. But I would suggest to use real logging instead of the standard output.