How to find all live threads in JVM?

Java JMX API provides you some useful classes to find out details about your JVM. One of those classes is ManagementFactory, This class provides API to find meta data about the JVM. In the below given example we will find all the live threads in the JVM and its state.

Console output.