code: public ThreadUsage getThreadUsage() {
          ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
  
          ThreadUsage threadUsage = new ThreadUsage();
          long[] threadIds = threadMxBean.getAllThreadIds();
          threadUsage.liveThreadCount = threadIds.length;
  
          for (long tId : threadIds) {
              ThreadInfo threadInfo = threadMxBean.getThreadInfo(tId);
              threadUsage.threadData.put(Long.toString(tId), new ThreadData(
                      threadInfo.getThreadName(), threadInfo.getThreadState()
                              .name(), threadMxBean.getThreadCpuTime(tId)));
  
          }
          return threadUsage;
      }
docs: Gets the thread usage.
  
  @return the thread usage