一:jps : 虚拟机进程状况工具:
jps(JVM Process Status Tool) ,可以列出正在运行的虚拟机进程,并显示虚拟机执行主类的名称,以及进程的本地虚拟机的唯一id
二:jstat: 虚拟机统计信息监视工具:
jstat(JVM Statistics Monitoring Tool )是用于监视虚拟机各种运行状态信息的命令行工具。可以显示本地或远程虚拟机进程中的类装载、内存、垃圾收集、JIT编译等运行数据。
三:JConsole: Java监视与管理控制台:
JConsole 是一款基于JMX的可视化监视和管理的工具。
四:JVisual 插件 BTrace使用(监视程序):
实际代码:
public class ThreadUtils { public int add(int a, int b){ return a+b; } public static void main(String[] args) throws IOException { ThreadUtils test = new ThreadUtils(); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); for (int i=0;i<10;i++){ reader.readLine(); int a = (int) Math.round(Math.random() *1000); int b = (int) Math.round(Math.random() *1000); System.out.println(test.add(a,b)); } } }
BTrace 代码: