code: public static synchronized String getLocalHostName(int timeoutMs) {
      if (sLocalHost != null) {
        return sLocalHost;
      }
  
      try {
        sLocalHost = InetAddress.getByName(getLocalIpAddress(timeoutMs)).getCanonicalHostName();
        return sLocalHost;
      } catch (UnknownHostException e) {
        throw new RuntimeException(e);
      }
    }
docs: Gets a local host name for the host this JVM is running on.
  
  @param timeoutMs Timeout in milliseconds to use for checking that a possible local host is
  reachable
  @return the local host name, which is not based on a loopback ip address