RFR 8098798: Thread.join(ms) on Linux still affected by changes to the time-of-day clock

Martin Buchholz martinrb at google.com
Wed Sep 5 00:00:56 UTC 2018


On Tue, Sep 4, 2018 at 12:02 PM, Roger Riggs <Roger.Riggs at oracle.com> wrote:

>
>> One sharp corner is that wait(0) waits forever, and TimeUnit conversion
>> truncates.  You can probably avoid those problems via TimeUnit.timedWait.
>>
>> Not trivial since a long cannot hold the combined time of millis(long)
> and nanos (long) in a TimeUnit(Nanos)
> and the cumulative wait time needs to be measured by System.nanoTime().


This sort of code is never trivial, but ... in j.u.c. we usually convert to
nanos as soon as we can.  Yes, we lose some range for large inputs - we
saturate to 2^63 nanoseconds.  But 292 years ought to be enough for ...
people calling wait, if not for paleontologists.   And nanoTime will wrap
around then anyways.


More information about the core-libs-dev mailing list