code: public @Nonnull ThreadDumpRuntime fromCurrentProcess() throws IOException, InterruptedException {
          final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
          final int index = jvmName.indexOf('@');
  
          if (index < 1) throw new IOException("Unable to extract PID from " + jvmName);
  
          long pid;
          try {
              pid = Long.parseLong(jvmName.substring(0, index));
          } catch (NumberFormatException e) {
              throw new IOException("Unable to extract PID from " + jvmName);
          }
  
          return fromProcess(pid);
      }
docs: Extract runtime from current process.
  
  This approach is somewhat external and {@link JvmRuntimeFactory} should be preferred.