Monitoring with JConsole
JConsole is a monitoring tool that follows the JMX specification that allows you to get information about the execution of an application as the number of threads, memory use, or class loading. It is included with the JDK and it can be used to monitor local or remote applications. In this recipe, you will learn how to use this tool to monitor a simple concurrent application.
Getting ready
The example of this recipe has been implemented using the Eclipse IDE. If you use Eclipse or a different IDE, such as NetBeans, open it and create a new Java project.
How to do it...
Follow these steps to implement the example:
- Create a class named
Task
and specify theRunnable
interface. Implement therun()
method to write the message in the console during 100 seconds:
public class Task implements Runnable { @Override public void run() { Date start, end; start = new Date(); do { System.out.printf("...