Class FullThreadDump

java.lang.Object
com.reallifedeveloper.tools.FullThreadDump

public final class FullThreadDump extends Object
This FullThreadDump class demonstrates the capability to get a full thread dump and also detect deadlock remotely.

Based on code by Sun Microsystems, Inc. and Oracle.

Author:
Josh Bloch, Neal Gafter, RealLifeDeveloper
  • Constructor Summary

    Constructors
    Constructor
    Description
    FullThreadDump(String hostname, int port)
    Creates a new FullThreadDump object that is connected to a JMX server on the given host and port.
    Creates a new FullThreadDump object that is connected to a JMX server at the given JMXServiceURL.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a thread dump with information about all the threads running in the Java process being monitored by the JMX server connected to.
    static void
    main(String... args)
    Connects to a JMX server at the given host and port number and creates a thread dump that is logged on INFO level.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FullThreadDump

      public FullThreadDump(String hostname, int port) throws IOException
      Creates a new FullThreadDump object that is connected to a JMX server on the given host and port.
      Parameters:
      hostname - the name of the host running the JMX server
      port - the port number the JMX server is listening on
      Throws:
      IOException - if connection to the JMX server fails
    • FullThreadDump

      public FullThreadDump(JMXServiceURL url) throws IOException
      Creates a new FullThreadDump object that is connected to a JMX server at the given JMXServiceURL.
      Parameters:
      url - the JMXServiceURL of the JMX server
      Throws:
      IOException - if connection to the JMX server fails
  • Method Details

    • dump

      public List<String> dump() throws IOException
      Creates a thread dump with information about all the threads running in the Java process being monitored by the JMX server connected to.

      The information is meant to be read by humans and is not easily parsable.

      Returns:
      a list of strings with information about the threads, e.g., thread name, call stack an so on.
      Throws:
      IOException - if communication with the JMX server fails
    • main

      public static void main(String... args) throws IOException
      Connects to a JMX server at the given host and port number and creates a thread dump that is logged on INFO level.
      Parameters:
      args - should be one string on the form "hostname:port", e.g., "localhost:4711"
      Throws:
      IOException - if communication with the JMX server fails