RFR [6853696] (ref) ReferenceQueue.remove(timeout) may return null even if timeout has not expired

Martin Buchholz martinrb at google.com
Mon Feb 24 15:25:43 UTC 2014


On Mon, Feb 24, 2014 at 6:37 AM, roger riggs <roger.riggs at oracle.com> wrote:

>
>   if (System.nanoTime() > end) {
>


As I wrote many years ago,

To compare two nanoTime values

 long t0 = System.nanoTime();
 ...
 long t1 = System.nanoTime();

one should use t1 - t0 < 0, not t1 < t0, because of the possibility of
numerical overflow.

http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#nanoTime()



More information about the core-libs-dev mailing list