Mit folgendem Code:
try {
System.out.println(new Date());
InetAddress hostName = InetAddress.getLocalHost();
System.out.println(new Date());
} catch (UnknownHostException e) {
e.printStackTrace();
}
Ich bekomme diese Ausgabe:
Thu Oct 22 20:58:22 BST 2015
Thu Oct 22 20:58:52 BST 2015
Mit anderen Worten 30 Sekunden zur Ausführung. Maschine ist 2015 Macbook Pro mit Java 1.8.0_60.
Warum dauert das so lange?
InetAddress.getLocalHost()zu sehen, wo es die Zeit verbringt