On Tue, Sep 4, 2018 at 12:02 PM, Roger Riggs <roger.ri...@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.

Reply via email to