InetAddress.getLocalHost() 运行缓慢 (30+ 秒)
2022-08-31 12:12:58
使用以下代码:
try {
System.out.println(new Date());
InetAddress hostName = InetAddress.getLocalHost();
System.out.println(new Date());
} catch (UnknownHostException e) {
e.printStackTrace();
}
我得到这个输出:
Thu Oct 22 20:58:22 BST 2015
Thu Oct 22 20:58:52 BST 2015
换句话说,执行时间为30秒。机器是2015年Macbook Pro与Java 1.8.0_60。
为什么这需要这么长时间?