@Internal
  public static ThreadInfo @NotNull [] getThreadInfos(@NotNull ThreadMXBean threadMXBean, boolean sort) {
    ThreadInfo[] threads;
    try {
      threads = threadMXBean.dumpAllThreads(false, false);
    }
    catch (Exception ignored) {
      threads = threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), Integer.MAX_VALUE);
    }
    int o = 0;
    for (int i = 0; i < threads.length; i++) {
      ThreadInfo info = threads[i];
      if (info != null) {
        threads[o++] = info;
      }
    }
    threads = ArrayUtil.realloc(threads, o, ThreadInfo[]::new);
    if (sort) {
      sort(threads);
    }
    return threads;
  }
@Internal
  public static ThreadInfo @NotNull [] getThreadInfos(@NotNull ThreadMXBean threadMXBean, boolean sort)