code: public static String getPid() {
          if (pid == null) {
              String runtimeName = ManagementFactory.getRuntimeMXBean().getName();
              if (runtimeName == null) {
                  pid = "unknown";
              } else {
                  int index = runtimeName.indexOf('@');
                  if (index < 0) {
                      pid = runtimeName;
                  } else {
                      pid = runtimeName.substring(0, index);
                  }
              }
          }
          return pid;
      }
docs: Retrieves process ID for the current process.
  
  @return pid string retrieved from the process name.