[concurrency-interest] deadline and long overflow

David Holmes davidcholmes at aapt.net.au
Wed Apr 20 06:22:15 EDT 2016


Hi Peter,

 

Doesn’t this “self-correct” when we do

 

nanos = deadline - System.nanoTime();

 

David

 

From: concurrency-interest-bounces at cs.oswego.edu [mailto:concurrency-interest-bounces at cs.oswego.edu] On Behalf Of Peter Veentjer
Sent: Wednesday, April 20, 2016 8:05 PM
To: concurrency-interest at cs.oswego.edu
Subject: [concurrency-interest] deadline and long overflow

 

I have a question regarding dealing with deadlines and long overflow.

For example the following from the SynchronousQueue:

final long deadline = timed ? System.nanoTime() + nanos : 0L;

What would happen if someone calls queue.offer(item, Long.MAX_VALUE, NANOS) then deadline overflows and becomes negative. I see the same approach in other parts e.g. 

this.deadline = timed ? System.nanoTime() + nanos : 0L;

from the Phaser. Personally I like the simplicity; but my concern is regarding validity.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160420/052e27d7/attachment.html>


More information about the Concurrency-interest mailing list