What does -XX:+UseGetTimeOfDay as a parameter do?
Whilst working on a Java application I've come across the -XX:+UseGetTimeOfDay
parameter on a java command, I can't find much information about it.
Firstly, what does the -XX mean, and what would the UseGetTimeOfDay provide? I haven't seen these before and I'm wondering what they do, could it be something specific to my application or are these standard Java parameters开发者_C百科?
I don't know if it's still relevant now, but I found some documentation on it:
Instructs the JVM to use the GetTimeOfDay call instead of the mechanism used in earlier versions whereby the number of cpu ticks since the application started is used to calculate the current time. With this new mechanism, changes to the system date or time using date(1), adjtime(2), or time synchronization utilities such as ntp are not reflected in the date and time that Java™ returns, until the process is restarted. If your application requires that Java™ immediately reflects such system time changes, you can use the -XX:+UseGetTimeOfDay option, however you may notice a drop in performance.
In general, -X and -XX flags are ones which control the JVM (and are VM-specific).
From the HotSpot options page (which doesn't list this one):
- Options that begin with -X are non-standard (not guaranteed to be supported on all VM implementations), and are subject to change without notice in subsequent releases of the JDK.
- Options that are specified with -XX are not stable and are not recommended for casual use. These options are subject to change without notice.
Found this thread which says:
The HotSpot JVM uses the gettimeofday() system call to obtain date and time information.
For performance reasons a new mechanism is used that uses the number of CPU ticks since the application started, to calculate the current time. As a result, changes to the system date or time using date(1), adjtime(2) or time synchronization utilities such as ntp will not be reflected in the date and time that the Java program returns, until the process is restarted.
If your application requires that system time changes are immediately reflected, you can use the -XX:+UseGetTimeOfDay option to tell the JVM to use the gettimeofday call instead of the new, lightweight mechanism. However you may notice a drop in performance.
精彩评论