<div dir="ltr"><div><div>Thanks for the replies.<br><br></div>The question is not about waiting given amount of time; but the calculation of the deadline itself which can become negative due to overflow. So imagine you call:<br><br></div>queue.poll(Long.MAX_VALUE, NANOS) <br><br><div>then the deadline will be < 0 due to overflow.<br><br>The question is if it can happen that a blocking call fails with a timeout, perhaps immediately due to this deadline becoming negative. I made some small examples and it seems to self correct like David suggested but it feels a bit funny.<br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 20, 2016 at 3:52 PM, Doug Lea <span dir="ltr"><<a href="mailto:dl@cs.oswego.edu" target="_blank">dl@cs.oswego.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 04/20/2016 06:32 AM, Alex Otenko wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Wouldn’t that be a deadline of 500-odd years?<br>
</blockquote>
<br></span>
Overflow issues can occur in half that time though (around 292 years).<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Technically, overflow is a possibility. Practically - very unlikely.<br>
<br>
</blockquote>
<br></span>
Right. There is a disclaimer about this in System.nanotime:<br>
<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime--" rel="noreferrer" target="_blank">http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime--</a><br>
<br>
This could be repeated in every timing-related method, but isn't.<br>
<br>
-Doug<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Alex<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On 20 Apr 2016, at 11:05, Peter Veentjer <<a href="mailto:alarmnummer@gmail.com" target="_blank">alarmnummer@gmail.com</a><br></span><span class="">
<mailto:<a href="mailto:alarmnummer@gmail.com" target="_blank">alarmnummer@gmail.com</a>>> wrote:<br>
<br>
I have a question regarding dealing with deadlines and long overflow.<br>
<br>
For example the following from the SynchronousQueue:<br>
<br>
final long deadline = timed ? System.nanoTime() + nanos :0L;<br>
What would happen if someone calls queue.offer(item, Long.MAX_VALUE, NANOS)<br>
then deadline overflows and becomes negative. I see the same approach in other<br>
parts e.g.<br>
<br>
this.deadline = timed ? System.nanoTime() + nanos :0L;<br>
from the Phaser. Personally I like the simplicity; but my concern is regarding<br>
validity.<br>
_______________________________________________<br>
Concurrency-interest mailing list<br>
</span><a href="mailto:Concurrency-interest@cs.oswego.edu" target="_blank">Concurrency-interest@cs.oswego.edu</a> <mailto:<a href="mailto:Concurrency-interest@cs.oswego.edu" target="_blank">Concurrency-interest@cs.oswego.edu</a>><br>
<a href="http://cs.oswego.edu/mailman/listinfo/concurrency-interest" rel="noreferrer" target="_blank">http://cs.oswego.edu/mailman/listinfo/concurrency-interest</a><br>
</blockquote><span class="">
<br>
<br>
<br>
_______________________________________________<br>
Concurrency-interest mailing list<br>
<a href="mailto:Concurrency-interest@cs.oswego.edu" target="_blank">Concurrency-interest@cs.oswego.edu</a><br>
<a href="http://cs.oswego.edu/mailman/listinfo/concurrency-interest" rel="noreferrer" target="_blank">http://cs.oswego.edu/mailman/listinfo/concurrency-interest</a><br>
<br>
</span></blockquote><div class="HOEnZb"><div class="h5">
<br>
<br>
<br>
_______________________________________________<br>
Concurrency-interest mailing list<br>
<a href="mailto:Concurrency-interest@cs.oswego.edu" target="_blank">Concurrency-interest@cs.oswego.edu</a><br>
<a href="http://cs.oswego.edu/mailman/listinfo/concurrency-interest" rel="noreferrer" target="_blank">http://cs.oswego.edu/mailman/listinfo/concurrency-interest</a><br>
</div></div></blockquote></div><br></div>