JDK Commands

  • To get pid of the java
    cd to jdk_folder/bin
    jps -lv
  • To get thread dump
    • Using the jstack cd to jdk_folder/bin
      jstack -F pid
    • Using JVisualVM cd to jdk_folder/bin
      Click on jvisualvm.exe
      Local -> java pid -> Thread -> ThreadDump
    • Java Mission Control (JMC) Java applications running locally or deployed in production environments.
      cd to jdk_folder\bin
      JVM Browser -> start flieght recording -> Next -> Finish -> Thread -> Thread Dump
    • using java code
      ThreadMXBean thx= ManagementFactory.getThreadMXBean();
      long[] tids = thx.getAllThreadIds();
      ThreadInfo[] thinfo = thx.getThreadInfo(tids);
      Arrays.stream(thinfo).forEach(
      (th) ->
      {
      System.out.println("Thread Name "+th.getThreadName());
      System.out.println(""+th.getBlockedCount());
      });

No comments:

Post a Comment