[ 
https://issues.apache.org/jira/browse/LOG4J2-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14375190#comment-14375190
 ] 

Mikhail Mazurskiy commented on LOG4J2-982:
------------------------------------------

It is wall clock time, right? If you adjust time on your system, it will jump. 
If something like ntpd is running, it can make it slew. Also think about 
virtualization - the drift is much worse there unless you have ntpd running. 
Also it looks like you have answered you own question (the link) =)

p.s. as for the bug in JDK - the program, that is doing the measurement, is 
wrong. Take a look at this blogpost 
http://shipilev.net/blog/2014/nanotrusting-nanotime/

p.p.s. Also some code (e.g. in tests and benchmarks) is already using nanoTime 
to do measurements. I just wanted to fix other places.

> Use System.nanoTime() to measure time intervals
> -----------------------------------------------
>
>                 Key: LOG4J2-982
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-982
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Core, Flume Appender
>            Reporter: Mikhail Mazurskiy
>            Priority: Minor
>         Attachments: LOG4J2-982.patch
>
>
> Unlike {{System.currentTimeMillis()}}, which can jump/slew forward and 
> backwards, {{System.nanoTime()}} is a monotonic clock (at least it should be) 
> and hence it should be used to measure time intervals (timeouts/delays/etc).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to